raxx_session v0.1.0 Raxx.Session
Working with sessions in Raxx applications.
A session is extracted from a request using fetch/2
.
They can be updated or dropped by using put/3
or drop/2
on a response.
Configuration
All session functions take a configuration as a parameter. To check configuration only one it is best to configure a session, and it's store, at startup.
When using the SignedCookie
store then sessions are compatible with sessions from plug applications.
Options
:store
- session store module (required):key
- session cookie key (required)
Cookie options
Any option that can be passed as an option to SetCookie.serialize/3
can be set as a session option.
:domain
, :max_age
, :path
, :http_only
, :secure
, :extra
Store options
Additional options may be required dependant on the store module being used.
For example SignedCookie
requires secret_key_base
and salt
.
Link to this section Summary
Functions
Set up and check session configuration.
Instruct a client to end a session.
Fetch a session from a request.
Overwrite a users session to a new value.
Link to this section Functions
config(options)
Set up and check session configuration.
See options for details.
drop(response, config)
Instruct a client to end a session.
fetch(request, config)
Fetch a session from a request.
Returns {:ok, nil}
if session cookie is not set.
When session cookie is set but cannot be decoded or is tampered with an error will be returned.
put(response, session, config)
Overwrite a users session to a new value.
The whole session object must be passed to this function.