Pow v1.0.0-rc.1 PowPersistentSession.Plug.Cookie View Source
This plug will handle persistent user sessions with cookies.
By default, the cookie will expire after 30 days. The cookie expiration will be renewed on every request. The token in the cookie can only be used once to create a session.
Example
defmodule MyAppWeb.Endpoint do
# ...
plug Pow.Plug.Session, otp_app: :my_app
plug PowPersistentSession.Plug.Cookie
#...
end
Configuration options
:persistent_session_store
- seePowPersistentSession.Plug.Base
:cache_store_backend
- seePowPersistentSession.Plug.Base
:persistent_session_cookie_key
- session key name. This defaults to “persistent_session_cookie”. If:otp_app
is used it’ll automatically prepend the key with the:otp_app
value.:persistent_session_cookie_max_age
- max age for cookie in seconds. This defaults to 30 days in seconds.
Link to this section Summary
Functions
Authenticates a user with the persistent session cookie
Sets a persistent session cookie with an auto generated token
Expires the persistent session cookie
Link to this section Functions
authenticate(Plug.Conn.t(), Pow.Config.t()) :: Plug.Conn.t()
Authenticates a user with the persistent session cookie.
If a persistent session cookie exists, it’ll fetch the credentials from the persistent session cache, and create a new session and persistent session cookie. The old persistent session cookie and session cache credentials will be removed.
The cookie expiration will automatically be renewed on every request.
call(Plug.Conn.t(), Pow.Config.t()) :: Plug.Conn.t()
create(Plug.Conn.t(), map(), Pow.Config.t()) :: Plug.Conn.t()
Sets a persistent session cookie with an auto generated token.
The token is set as a key in the persistent session cache with the user struct id.
The unique cookie id will be prepended by the :otp_app
configuration
value, if present.
delete(Plug.Conn.t(), Pow.Config.t()) :: Plug.Conn.t()
Expires the persistent session cookie.
If a persistent session cookie exists it’ll be expired, and the token in the persistent session cache will be deleted.