Access the current login user in different action

The problems is
I store the :player witin tables method, I also need accss it in the table method but the :player isn’t there.
Is there any way to implement this?

My code:

defmodule Test.PageController do
  use Test, :controller

  def index(conn, _params) do
    render(conn, "index.html")

  def tables(conn, %{"player" => name}) do
    |> assign(:player,name)
    |> render("tables.html")

  def table(conn, %{"table" => table}) do
    IO.inspect(conn), {:join, conn.assigns[:player]})
    render(conn, "table.html")

Thanks for help this!

What do you mean by “it isn’t there”?

The IO.inspect in tables/2 should print it.

You have to store that in a session. assign/3 doesn’t store anything, it only assigns a key to the current conn.

Use put_session/3 and get_session/3 instead, but be considerate of any security implications. By default, the session is stored as a cookie. It’s encrypted, so it’s pretty safe, but industry practice is to not store any identifying information in a session cookie at all, and just use a random generated id to pull the information on subsequent requests.

I try to access conn.assign[:player] in table but it’s empty.

Thanks man ! That’s what I needed.