Plug.Session.Store behaviour
Specification for session stores.
Summary
Types
- cookie()
The cookie value that will be sent in cookie headers. This value should be base64 encoded to avoid security issues.
- session()
The session contents, the final data to be stored after it has been built with
Plug.Conn.put_session/3
and the other session manipulating functions.- sid()
The internal reference to the session in the store.
Functions
- get(store)
Gets the store name from an atom or a module.
Callbacks
- delete(arg1, sid, arg3)
Removes the session associated with given session id from the store.
- get(arg1, cookie, arg3)
Parses the given cookie.
- init(arg1)
Initializes the store.
- put(arg1, sid, any, arg4)
Stores the session associated with given session id.
Types
cookie()
Specs
cookie() :: binary()
The cookie value that will be sent in cookie headers. This value should be base64 encoded to avoid security issues.
session()
Specs
session() :: map()
The session contents, the final data to be stored after it has been built with Plug.Conn.put_session/3
and the other session manipulating functions.
sid()
Specs
sid() :: term() | nil
The internal reference to the session in the store.
Functions
get(store)
Gets the store name from an atom or a module.
iex> Plug.Session.Store.get(CustomStore) CustomStore iex> Plug.Session.Store.get(:cookie) Plug.Session.COOKIE
Callbacks
delete(arg1, sid, arg3)
Specs
delete(Plug.Conn.t(), sid(), Plug.opts()) :: :ok
Removes the session associated with given session id from the store.
get(arg1, cookie, arg3)
Specs
get(Plug.Conn.t(), cookie(), Plug.opts()) :: {sid(), session()}
Parses the given cookie.
Returns a session id and the session contents. The session id is any value that can be used to identify the session by the store.
The session id may be nil in case the cookie does not identify any value in the store. The session contents must be a map.
init(arg1)
Specs
init(Plug.opts()) :: Plug.opts()
Initializes the store.
The options returned from this function will be given to get/3
, put/4
and delete/3
.
put(arg1, sid, any, arg4)
Specs
put(Plug.Conn.t(), sid(), any(), Plug.opts()) :: cookie()
Stores the session associated with given session id.
If nil
is given as id, a new session id should be generated and returned.
© 2013 Plataformatec
Licensed under the Apache License, Version 2.0.
https://hexdocs.pm/plug/Plug.Session.Store.html