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

plug PowPersistentSession.Plug.Cookie

#...

end

Configuration options

  • :persistent_session_store the persistent session store
  • :cache_store_backend the backend cache store
  • :persistent_session_cookie_key session key name
  • :persistent_session_cookie_max_age max age for cookie

Link to this section Summary

Functions

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

Sets a persistent session cookie with an auto generated token, and sets the token as a key in the persistent session cache with the credentials

If a persistent session cookie exists, it’ll be expired, and the key in the persistent session cache will be removed

Link to this section Functions

Link to this function authenticate(conn, config) View Source
authenticate(Plug.Conn.t(), Pow.Config.t()) :: Plug.Conn.t()

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, and sets the token as a key in the persistent session cache with the credentials.

If a persistent session cookie exists, it’ll be expired, and the key in the persistent session cache will be removed.