# Live View Session Management

**URL:** <https://forum.elixirforum.com/t/live-view-session-management/43203>\
**Category:** Questions\
**Tags:** phoenix, liveview\
**Created:** [October 19, 2021, 6:16pm UTC](https://forum.elixirforum.com/t/live-view-session-management/43203 "2021-10-19T18:16:36Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![andrewb](https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/andrewb/32/20567_2.png) [@andrewb](https://forum.elixirforum.com/u/andrewb)\
**Post date:** [October 19, 2021, 9:35pm UTC](https://forum.elixirforum.com/t/live-view-session-management/43203/2 "2021-10-19T21:35:11Z")

</div>

Hi @shortlyportly,

I was playing with `live_session` yesterday. I think it depends on what you want to use the session for but if it is to get information based on the session and populate the `socket.assigns` then the new `live_session` now has you covered.

You can create a `Module` that gets called using the `on_mount` hook (It works like `Plug`) and you can grab anything you need from the session and add it to the socket before `mount` is called. The main benefit is to reduce the boilerplate code on every `LiveView`.

Yesterday I moved the `assign(socket, :current_user, user)` to and `on_mount` `Module` and it works great. There is an example in the docs [here](https://hexdocs.pm/phoenix_live_view/security-model.html#authentication-vs-authorization)

Andrew

---

_[View the full topic](https://forum.elixirforum.com/t/live-view-session-management/43203)._
