更新时间:2023-02-19 19:00:52
默认cookie"max-age"直到关闭浏览器为止. 您应该给cookie一个非常高的"max_age"值: http://hexdocs.pm/plug/Plug.Conn.html#put_resp_cookie/4
The default cookie "max-age" is until close borwser. You should give the cookie a really high "max_age" value: http://hexdocs.pm/plug/Plug.Conn.html#put_resp_cookie/4
另一种设置"max_age"的方法,在官方文档中找不到,但是它有效:
Another way set "max_age", I can't find it in official doc,but it works:
defmodule HelloPhoenix.Endpoint do
use Phoenix.Endpoint, otp_app: :hello_phoenix
. . .
plug Plug.Session,
store: :cookie,
key: "_hello_phoenix_key",
signing_salt: "Jk7pxAMf",
max_age: 2592000 # 60*60*24*30
. . .
end