INTRO
The n2o_session module provides session variables protected by authorization token.
> ets:tab2list(cookies).
[{{<<"05dcf467c79071008bc4">>,user},{63710034516,"maxim"}},
{{<<"05dcf467c79071008bc4">>,room},{63710034516,"n2o"}},
{{<<"05dcf467c79071008bc4">>,auth},{63710033891,[]}}]
TYPES
Session token represents tuple cached in ETS. It consists of session id, key, expiration time and value. Session token used both for auth and for session variables.
-type expires() :: integer().
-type session_sid() :: binary().
-type session_key() :: { session_sid() , term() }.
-type session_val() :: { expires() , term() }.
-type session() :: { session_key() , session_val() }.
Session token encoded with pickler tagged as 'Token' tuple.
-type token() :: { 'Token', binary() }.
API
authenticate([], binary()) -> token().
The protocol is following. If session is expired or session token is invalid then new session token issued. If session token is not expired and valid then two cases could happen: 1) if nitro_prolongate n2o parameter is true, then new expiration value is updated for current session, while session sid remains unchanged; 2) if nitro_prolongate is false then full session token remains unchanged.
get_value(binary(), term(), term()) -> term().
set_value(binary(), term(), term()) -> term().
storage() -> atom().
prolongate() -> boolean().
BACKEND
clear(binary()) -> ok.
update(session()) -> ok.
delete(session_key()) -> ok.
lookup(session_key()) -> ok.
invalidate_sessions() -> ok.