sandeshsoni
just another Phoenix App with LiveView.
We have @ current_user in our session data.
Additionally, I want to store current_region of user…
lets say when users opens in browser my_domain_com a default current_region like abc must be set.
Instead if user visits my_domain_com / region/r_123 , I want r_123 to be stored in session data under current_region. (Assume QR code is scanned and it opens this link.)
Yes, I read LiveView cannot store/edit session data. Looking for simple hack if anyone has used. I dont understand the need of phx-hook here in this case.
This is one of nearest blogs I came across,
scope "/", AtmanirbharWeb do
pipe_through :browser
live "/", PageLive, :index
The possible Idea clicks in my mind, instead of live make this a get request. Confused so posting the question here.
Still open to other ideas and implementations.
Trending in Questions
Other Trending 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
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #blog-post
- #elixir-ls
- #ai
- #elixirconf-us
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #hex
- #security
- #metaprogramming










Showing Posts 1 to 2- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
outlog
use a plug? or a controller for /region/r_123 that quickly sets cookie and redirects to /region
sfusato
I use a similar approach like the one described in the article you linked. The
phx-hookwill be present in a template used on your/region/r_123route like and will fire an AJAX call to updatecurrent_regionin the session.A plug will only work on the first render in a LV scenario. Any further LV navigation (going from region to region in this case) won’t go through the plug, thus the session won’t be updated.