Module z_session

Session for zotonic, holds all information for the current session at an user agent.

Copyright 2009-2014 Marc Worrell

Behaviours: gen_server.

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

Description

Session for zotonic, holds all information for the current session at an user agent. An agent can have multiple pages open and an user_session can have multiple sessions. The user agent session also starts and monitors the page sessions.

Function Index

add_cookie/4Store a cookie on the session.
add_script/1Split the scripts from the context and add the scripts to the session pages.
add_script/2Send a script to all session pages.
check_expire/2Check session and page expiration, periodically called by the session manager.
clear_cookies/1Resets cookies temporarily stored on the session.
code_change/3Convert process state when code is changed.
dump/1Dump the session details.
ensure_page_session/1Make sure that the request has a page session, when the page session was alive then adjust the expiration of the page.
get/2Get a session value.
get/3Get a session value with a default.
get_attach_state/1Check the state of all the attached pages.
get_cookies/1Get cookies stored on the session.
get_pages/1Get app page pid()'s that are attached to the session.
get_persistent/2
get_persistent/3
handle_call/3Handling call messages.
handle_cast/2
handle_info/2
incr/3
init/1
keepalive/1Reset the expire counter of the session, called from the page process when comet attaches.
keepalive/2Reset the timeout counter of the page and session according to the current tick.
lookup_page_session/2Lookup a page session (if any).
persistent_id/1
receive_ack/2Ack a message, removes it from the retry queue.
set/2
set/3
set_persistent/3
spawn_link/4Spawn a new process, linked to the session pid.
start_link/2
stop/1
terminate/2This function is called by a gen_server when it is about to terminate.
transport/2Send a msg to all attached pages, queue if no pages.

Function Details

add_cookie/4

add_cookie(Key, Value, Options, Context) -> any()

Store a cookie on the session. Useful for setting cookies from a websocket connection.

add_script/1

add_script(Context) -> Context1

Split the scripts from the context and add the scripts to the session pages.

add_script/2

add_script(Script::io_list(), PagePid::pid()) -> none()

Send a script to all session pages

check_expire/2

check_expire(Now::integer(), Pid::pid()) -> none()

Check session and page expiration, periodically called by the session manager

clear_cookies/1

clear_cookies(Context) -> any()

Resets cookies temporarily stored on the session.

code_change/3

code_change(OldVsn, Session::State, Extra) -> {ok, NewState}

Convert process state when code is changed

dump/1

dump(Pid) -> any()

Dump the session details

ensure_page_session/1

ensure_page_session(Context::#context{}) -> #context{}

Make sure that the request has a page session, when the page session was alive then adjust the expiration of the page. Returns a new context with the page id set.

get/2

get(Key, Context) -> any()

Get a session value. Defaults to 'undefined'.

get/3

get(Key, Context, DefaultValue) -> any()

Get a session value with a default.

get_attach_state/1

get_attach_state(Context::#context{}) -> [States]

Check the state of all the attached pages.

get_cookies/1

get_cookies(Context) -> any()

Get cookies stored on the session.

get_pages/1

get_pages(Pid) -> any()

Get app page pid()'s that are attached to the session

get_persistent/2

get_persistent(Key, Context) -> any()

get_persistent/3

get_persistent(Key, Context, DefaultValue) -> any()

handle_call/3

handle_call(Msg::Request, From, Session::State) -> {reply, Reply, State} | {reply, Reply, State, Timeout} | {noreply, State} | {noreply, State, Timeout} | {stop, Reason, Reply, State} | {stop, Reason, State}

Handling call messages

handle_cast/2

handle_cast(Msg, Session) -> any()

handle_info/2

handle_info(X1::Info, Session::State) -> {noreply, State} | {noreply, State, Timeout} | {stop, Reason, State}

incr/3

incr(Key, Value, Context) -> any()

init/1

init(X1) -> any()

keepalive/1

keepalive(Pid) -> any()

Reset the expire counter of the session, called from the page process when comet attaches

keepalive/2

keepalive(PageId, Pid) -> any()

Reset the timeout counter of the page and session according to the current tick

lookup_page_session/2

lookup_page_session(PageId, Context) -> any()

Lookup a page session (if any)

persistent_id/1

persistent_id(Context) -> any()

receive_ack/2

receive_ack(Ack, Pid) -> any()

Ack a message, removes it from the retry queue

set/2

set(Props, Context) -> any()

set/3

set(Key, Value, Context) -> any()

set_persistent/3

set_persistent(Key, Value, Context) -> any()

spawn_link/4

spawn_link(Module, Func, Args, Context) -> any()

Spawn a new process, linked to the session pid

start_link/2

start_link(PersistId, Context) -> any()

stop/1

stop(SessionPid) -> any()

terminate/2

terminate(Reason, Session::State) -> void()

This function is called by a gen_server when it is about to terminate. It should be the opposite of Module:init/1 and do any necessary cleaning up. When it returns, the gen_server terminates with Reason. The return value is ignored. Terminate all processes coupled to the session.

transport/2

transport(Msg, Pid) -> any()

Send a msg to all attached pages, queue if no pages


Generated by EDoc, Nov 24 2014, 19:13:20.