Module z_session_manager

User agent session management for zotonic.

Copyright 2009-2014 Marc Worrell

Behaviours: gen_server.

Authors: Marc Worrell (marc@worrell.nl).

Description

User agent session management for zotonic. A ua session is a process started for every user agent visiting the site. The session is alive for a fixed period after the last request has been done. The session manager manages all the ua session processes.

Data Types

session_id()

session_id() = binary()

Function Index

add_script/1Send the scripts in the context to all pages of all sessions.
add_script/2Send a script to all pages of all sessions.
broadcast/2Broadcast a notification message to all open sessions.
code_change/3
continue_session/1Continue an existing session.
count/1Return the number of open sessions.
dump/1Dump all session to stdout.
ensure_session/1Start a new session or continue an existing session.
fold/3Calls Fun on successive sessions together with an extra argument Acc (short for accumulator).
foreach/2Apply the given function to all sessions.
get_session_id/1Fetch the session id.
handle_call/3
handle_cast/2
handle_info/2
init/1Initialize the session server with an empty session table.
rename_session/1Rename the session id, only call this after ensure_session.
start_link/1Starts the session manager server.
start_session/3
stop_session/1Explicitly stop an existing session.
stop_session/2
terminate/2
tick/1Periodic tick used for cleaning up sessions.
whereis/2Find the session with the given id.
whereis_user/2Find all the sessions for a certain user.

Function Details

add_script/1

add_script(Context) -> none()

Send the scripts in the context to all pages of all sessions

add_script/2

add_script(Script::io_list(), Context) -> none()

Send a script to all pages of all sessions

broadcast/2

broadcast(Broadcast::#broadcast{}, Context) -> ok

Broadcast a notification message to all open sessions.

code_change/3

code_change(OldVersion, State, Extra) -> any()

continue_session/1

continue_session(Context::#context{}) -> {ok, #context{}} | {error, term()}

Continue an existing session. No new session will be created.

count/1

count(Context) -> Int

Return the number of open sessions

dump/1

dump(Context) -> void()

Dump all session to stdout

ensure_session/1

ensure_session(Context::#context{}) -> {ok, #context{}} | {error, term()}

Start a new session or continue an existing session

fold/3

fold(Function::function(), Acc0::term(), Context::#context{}) -> Acc::term()

Calls Fun on successive sessions together with an extra argument Acc (short for accumulator). Fun must return a new accumulator which is passed to the next call. Acc0 is returned if the list is empty. The evaluation order is undefined.

foreach/2

foreach(Function::function(), Context::#context{}) -> void()

Apply the given function to all sessions

get_session_id/1

get_session_id(Context::#context{}) -> undefined | session_id()

Fetch the session id

handle_call/3

handle_call(Msg, From, State) -> any()

handle_cast/2

handle_cast(Msg, Session_srv) -> any()

handle_info/2

handle_info(Msg, State) -> any()

init/1

init(SiteProps) -> {ok, State}

Initialize the session server with an empty session table. We make the session manager a system process so that crashes in sessions are isolated from each other.

rename_session/1

rename_session(Context::#context{}) -> {ok, #context{}} | {error, term()}

Rename the session id, only call this after ensure_session

start_link/1

start_link(SiteProps::list()) -> {ok, pid()} | ignore | {error, term()}

Starts the session manager server

start_session/3

start_session(Action::optional | ensure, CurrentSessionId::session_id(), Context::#context{}) -> {ok, #context{}} | {error, term()}

stop_session/1

stop_session(Context::#context{}) -> {ok, #context{}} | {error, term()}

Explicitly stop an existing session

stop_session/2

stop_session(SessionId::binary(), Context::#context{}) -> ok | {error, term()}

terminate/2

terminate(Reason, State) -> any()

tick/1

tick(SessionManager::pid()) -> void()

Periodic tick used for cleaning up sessions

whereis/2

whereis(SessionId::session_id(), Context::#context{}) -> pid() | undefined

Find the session with the given id

whereis_user/2

whereis_user(UserId::integer() | undefined, Context::#context{}) -> [pid()]

Find all the sessions for a certain user


Generated by EDoc, Nov 24 2014, 09:54:10.