Pow v0.1.0-alpha.6 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_web

plug PowPersistentSession.Plug.Cookie

#...

end

Configuration options

  • :persistent_session_store - see PowPersistentSession.Plug.Base

  • :cache_store_backend - see PowPersistentSession.Plug.Base

  • :persistent_session_cookie_key session key name. This defaults to “persistent_session_cookie”.

  • :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

Link to this function authenticate(conn, config) View Source
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.

Link to this function create(conn, map, config) View Source
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.

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.