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

xeisu's avatar
Level 1

Saving a Long Term Session in Livewire?

I have a social network and want to store my own likes in a session since there are many subpages where I need this data and I want to avoid querying the database for that on every page. However you can only save flash data in sessions in Livewire.

The usual Laravel $request->session()->put(...) feature to save data long term in sessions doesn't seem to work in Livewire? So how could I save data long term in sessions or is there an other option or feature?

0 likes
4 replies
Nakov's avatar
Nakov
Best Answer
Level 73

So instead of the $request->session() have you tried using the session() helper itself?

session()->put(...)
1 like
xeisu's avatar
Level 1

Ahh, great, thanks! This isn't documented, so good to know. Works perfectly.

xeisu's avatar
Level 1

@webrobert I meant in the Livewire docs. It leaves the impression that you just can use flash() since using $request doesn't work there.

Please or to participate in this conversation.