How to share assigns that comes from a deadview, with a lv with only on-mount functions

im assigning a user_id in a deadview which is then supposed to redirect to a liveview page. But that page is within a live session, which has another liveview with only on_mount functions doing some work. But the assign from the deadview is lost after the redirection. If I assign_new something in these o_mount callbacks, it shows up in the regular liveview pages but I need the assign from the deadview to be present. How do I do that. Ive also done put_session in the same deadview & that works fine, the session data is coming throught but the assign is lost, how do I fix this?

In short, you can’t the way you’re describing. Dead views are dead—just regular ol’ stateless HTTP requests whose assignss die with it. You’re most of the way there, though, since you’re storing the what you need in a session. You can pull it out of the third parameter in on_mount. It sounds like you know this, though, so you just have to reconstruct your user from its id there.

Some info can be found here. EDIT: Meant to link this header.

According to the assign_new docs, it can be done, if you look at the section of sharing assigns with liveviews when disconnected. So we can do assigns in a deadview & get it in the mount callback of another liveview, but in my case, it goes to an in between on_mount callback first & somehow looses the original assign.
I can pull it out of the session yes, but everytime a request is made, the on_mount callback is implemented which pulls out the session from the db for every request. this is wasteful & something id like to avoid

The docs say:

It is possible to share assigns between the Plug pipeline and LiveView on disconnected render and between LiveViews when connected.

This is not the same as redirecting from a dead view to a live one. Once you are navigating between live views within the same live_session, the current_user will stay in the socket.

oh right, so you suggest I should turn this into a plug, maybe I can test it out. Lets hope it works.
Ill update you on the result

This post might help clear up the situation some:

disclaimer: I wrote it

yep, thanks for this. I figured it out. I just wanted to avoid db calls on every request, which is solved without the need of using plugs etc. & by simply binding the socket everytime with the same data if user_id is present else with a changed data which includes user_id fetched via a db call in the assign_new.

Thanks for the help.

For the record I was not suggesting you use plugs, lol, just pointing out the docs were actually saying.

Glad you figured it out!

yep np!. i was using normal controllers & that didnt work, but now it does. Although there are edge cases to my implementation, but those shouldnt arise under normal circumstances unless someone really tries to fiddle with things theyre not meant to fiddle with so ig im good for now