vfsoraki

vfsoraki

How does session work in LiveView

In mount/3 callback of a LiveView module, you get session as the second parameter. It works fine, until you use live_redirect/push_redirect to mount another LiveView.

In this case, what is the session passed to second one? The same as original?

Is there a way to change it, without some hacky thing?

I currently did it by using JS to append some signed query string to my url and reload the page, and a plug that reads that signed string and sets appropriate session values, but this feels kind of hacky.

My current use case is user settings page. User changes some settings, then hits save, then goes to another page. User settings is saved in database, but session data is still old, so when new LiveViews are mounted they still see the old setting.

Most Liked

wanton7

wanton7

Googled a bit about this issue and came across this thread that might help you How to manage session state with live view

Last Post!

vfsoraki

vfsoraki

Nice solutions were provided at the end of that topic, but they seem kind of hacky as my solution. Thanks!

Where Next?

Popular in Questions Top

minhajuddin
I have seen a lot of code which picks the first element from a list using Enum.at(0) instead of List.first. Is there a reason why people ...
New
Emily
I have VueJS GUIs with the project generated using Webpack. I have Elixir modules that will need to be used by the VueJS GUIs. I forese...
New
aadeshere1
I have a another noob question about loop. Since elixir is immutable, while loop is not directly possible. total = 10 while total != 0 ...
New
fireproofsocks
Forgive me if this is obvious, but how does one delete a database record WITHOUT selecting it first? Ecto.Repo — Ecto v3.14.0 has exampl...
New
aalberti333
As the title describes, I’m trying to run Enum.map() over a list of key/value pairs, where the value is a map. My data looks like this: ...
New
Harrisonl
We have an ECS cluster with 4 services, where each task joins a single cluster, via discovery ECS discovery service. Currently when I de...
New
jason.o
In the code below, if the create action is not set to accept “extra_key” as an input, it errors out with a message shown above. Is there ...
New

Other popular topics Top

Qqwy
Update: How to use the Blogs & Podcasts section You can post links to your blog posts or podcasts either in one of the Official Blog...
3271 130579 1222
New
vertexbuffer
Hello, can anybody help here..? I have a list of players and I what to delete an element, but every for loop the list is reverting to ori...
New
hariharasudhan94
I would like to know what is the best IDE for elixir development?
New
gausby
I asked this very same question on twitter and got some interesting feedback, but I thought it would be a good question to ask here as we...
1207 40082 209
New
AngeloChecked
What learn first? Rust or Elixir Hi Elixir community! I’m here because i want learn a new language. I’m a junior developer and mainly i ...
New
Harrisonl
We have an ECS cluster with 4 services, where each task joins a single cluster, via discovery ECS discovery service. Currently when I de...
New

We're in Beta

About us Mission Statement