# Set the LiveView socket session opts dynamically

**URL:** <https://forum.elixirforum.com/t/set-the-liveview-socket-session-opts-dynamically/70131>\
**Category:** Questions\
**Tags:** phoenix, session, liveview\
**Created:** [March 25, 2025, 2:45pm UTC](https://forum.elixirforum.com/t/set-the-liveview-socket-session-opts-dynamically/70131 "2025-03-25T14:45:42Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![jeroenbourgois](https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/jeroenbourgois/32/6720_2.png) [@jeroenbourgois](https://forum.elixirforum.com/u/jeroenbourgois)\
**Post date:** [March 25, 2025, 2:48pm UTC](https://forum.elixirforum.com/t/set-the-liveview-socket-session-opts-dynamically/70131/2 "2025-03-25T14:48:55Z")

</div>

Ok, I am an idiot who does not RTFM… Sorry

```elixir
socket "/live", MyAppWeb.UserSocket,
  websocket: [connect_info: [session: { __MODULE__ , :runtime_opts, []}]]

# ...

def runtime_opts() do
  Keyword.put(@session_options, :domain, host())
end

```

However, this will not allow me to access the `conn` object, which I need in order to determine the correct domain name.

---

_[View the full topic](https://forum.elixirforum.com/t/set-the-liveview-socket-session-opts-dynamically/70131)._
