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
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
Nice solutions were provided at the end of that topic, but they seem kind of hacky as my solution. Thanks!
Popular in Questions
Other popular topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #elixirconf-us
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #metaprogramming
- #security
- #hex









