Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Dean5's avatar
Level 1

Livewire - Session not working correctly

Hi all,

I'm having an issue with Livewire and session data seems to be automatically cached by Livewire:

  • I have a Livewire component "1" that allows you to select a store from a list,

  • Once a store is selected, a Livewire function is triggered via wire:click to save the selected store session and a withdrawal hour in session,

  • Another Livewire component "2" allows you to display the selected store and the withdrawal hour,

  • This Livewire component "2" at the time of mount(), checks if the withdrawal hour is not less than the current one, if yes we modify the withdrawal hour by modifying the session via session()->put(). -> It is at this step that the problem appears, the session is indeed modified when the component is displayed and the modified withdrawal hour appears. On the other hand, if I refresh the page or change pages, the saved session is always the old one. Likewise if I display the session in a classic controller, I have the old value. I am forced to F5 the page several times for the new value to be definitively saved. It seems that session manipulation is only done locally inside the component but not globally in case it is done without user action.

Has anyone encountered this issue before?

Thanks!

0 likes
3 replies
tominal's avatar

I can confirm the same behavior on Laravel 11 Livewire 3. wire:click has a different session()->getId() per click. So it's treating the XHR as a whole separate session. I wonder if that's intended?

Disregard. I have multi-tenancy in the other app. A blank app worked correctly., so I may have to set the update route correctly in Livewire. Using the setUpdateRoute fixed this correctly

1 like
thanhtrungit's avatar

@tominal Hi. please give me your solution: edit setUpdateRoute to fixed it? You can show your code in TenancyServiceProvider

Dean5's avatar
Level 1

I had indeed checked the Session ID too while Livewire was processing a different session but I have the same session ID.

I did a new test with a setTimeOut on a page that triggers a Livewire.dispatch on a function to change the session and it works fine.

From what I can see, the problem is only present when the session tries to be changed when the component is loaded via mount / boot or render.

I can't explain this behavior nor is it intentional! No information in the documentation or anywhere!

Please or to participate in this conversation.