5 ms·
I really enjoy working with LiveView and have personally built several substantially sized apps with it. One of my current frustrations is the inability, out-o
by stevencorona 4y ago
I really enjoy working with LiveView and have personally built several substantially sized apps with it.
One of my current frustrations is the inability, out-of-the-box, to write to sessions from LiveView. I understand the reason why, but I personally find the "redirect to a controller to set the cookie" pattern to be a bit hacky and more work than I'd like in order to just.. set a cookie.
I hope that a future release has a built-in pattern for writing sessions and cookies in general.
- prophesi 4y agoYep, we had to use https://github.com/pentacent/phoenix_live_session https://github.com/pentacent/phoenix_live_session and then made a PR for it to support Nebulex as an alternative to ETS. Hoping something like this makes it upstream.
- boxed 4y agoI don't understand. Why isn't the session cookie created at initial load, and then all the data in the session kept on the server side? Writing anything into a cookie except the session id seems weird to me. What am I missing?
- Ndymium 4y agoBy default Phoenix uses client side sessions. The session data is written into a cookie and signed (or encrypted) to prevent tampering.
- danielheath 4y agoSigned cookies are vastly simpler to scale. It’s a common enough problem that frameworks default to them.
- digianarchist 4y agoThat's done for security reasons though right? I thought browsers isolated http cookies from client side cookies.
- dugmartin 4y agoCould you use a 0 pixel 1st party iframe instead of a redirect to set the cookie? At least that way you could set and update it within the live view code (you would need a controller endpoint for the iframe still).