Now we need to devise a way to send the user ID of a logged-in user through the controller to the template and back again; this way, a user can be properly associated with every poll they create. To do this, we need to work with Phoenix's built-in session handling code. The good news is that getting data out of the session is just as easy as putting data into the session; essentially, the only difference is that we'll be calling get_session/2 instead of put_session/3.
Sending a user ID through the controller
Get Phoenix Web Development now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.