I wanna know where the session variables are stored [Plug.Conn.put_session]

Hi !!

I execute put_session.

conn = put_session(conn, :message, "new stuff we just set in the session")

and after I execute below.

    # conn = put_session(conn, :message, "new stuff we just set in the session")

    message = get_session(conn, :message)

    IO.inspect([message])

Then I can confirm put_session value in log.


["sample session value"]

Is there a way to know where the actuals of session variables are stored ?

For example, the actuals of session variables are stored at “/tmp/file_{session_id}” and I check file_{session_id} using “view file_{session_id}”.

thank you for reading !!

They’re stored in memory as part of the conn. At the start of a request they’re retrieved from the session store configured for Plug.Session and at the end of the request it’s stored back into that storage. The default session store for plug/phoenix is cookie based, so the values are persisted in an cookie on the http response and send back to the server by the browser. There are also server side session stores available.

2 Likes

thank you for reply !!

before i think saved value at cookie is “key”, and “value” is saved at server side.

When I know “cookie based” I can not understand. Because There was a gap with my own knowledge.
But “Cookie base” meant literally.

Thank you !!

I will answer if someone have the same question.