Hello,
I have installed a phoenix server (Phoenix 1.7) in my machine and have access to it locally by 192.168.1.2:4000
, I had a strange problem : the session always disappear between 2 different requests, here the code :
endpoint.ex
...
@session_options [
store: :cookie,
key: "some_key",
max_age: 60 * 60 * 24 * 30,
secure: true,
serrurier: Myapp.Session,
encryption_salt: "..."
signing_salt: "..."
]
plug Plug.Session, @session_options
plug MyappWeb.Router
end
router.ex
...
pipeline :browser do
plug :accepts, ["html"]
plug :fetch_session
plug MyappWeb.Plug.Session
plug :fetch_live_flash
plug :protect_from_forgery
plug MyappWeb.Plug.Attack
plug MyappWeb.Plug.RemoteAddr
...
end
myapp_web/plugs/session.ex
...
def call(conn, _opts) do
case get_session(conn, "my_session") do
nil -> IO.puts("session not found")
_session -> IO.puts("session found")
end
conn
end
...
And the controller where the session is to be stored
session_controller.ex
...
conn
|> configure_session(renew: true)
|> put_session("my_session", session)
|> redirect(conn, to: "/")
...
And the result is always the output session not found, so just why please ? (Iam using Android Chrome to access the server)
Thank you in advance.