Bric::App::Session - A class to handle user sessions
use Bric::App::Session;
#- Methods called from the apache perl handler -#
setup_user_session($r);
sync_user_session();
#- Methods called from widgets -#
[$new_state_name, $new_state_data] = init_state($widget, $state, $data);
$state_name = state_name($widget, $name);
$state_data = state_data($widget, ($data_hash || $name, $value));
[$state_name, $state_data] = state($widget, $state_name, $state_data);
This module provides all the necessary functions for maintaining state within widgets. This includes setting a global state variable $session as well as accessor methods for setting the state name of a widget and state data of a widget.
Return a reference to the %session hash so that other parts of the API can get the current session without using %HTML::Mason::Commands::session directly.
Throws:
NONE
Side Effects:
NONE
Notes:
NONE
#------------------------------------------------------------------------------#
This function takes an Apache request object and sets up the persistent user session hash. This hash is tied to an Apache::Session::File object.
Throws:
Difficulties tie'ing the session hash.
Side Effects:
Sends a cookie to the users browser.
Creates a session file on the file system.
Sets global variable '%session' in package 'HTML::Mason::Commands'.
Notes:
NONE
Synchronizes changes to the user session back to the file system.
Throws:
Unable to synchronize user session.
Side Effects:
Unties the global variable %HTML::Mason::Commands::session.
Notes:
NONE
Expires the user session, deleting it from the disk.
Throws:
Unable to expire user session.
Side Effects:
Deletes the global %HTML::Mason::Commands::session session object.
Notes:
NONE
If a widget has not yet been called and this function is called, it will set some default values for that widgets state name and state data.
Throws:
NONE
Side Effects:
Sets the global variable %HTML::Mason::Commands::session
Notes:
NONE
Set or get the current widget state name. A state name cannot be set to undef since it is bad style to rely on a state that you do not set explicitly. If you want to clear the state entirely, use clear_state.
Throws:
NONE
Side Effects:
Sets the global variable %HTML::Mason::Commands::session
Notes:
NONE
Get or set the state data. The set function takes either a hash or a key/value. Given a hash the set function will overwrite the state data. Given a key/value pair, it will set that key in the state data to that value.
The get function will return the whole state data hash if given just a widget. If passed a name it will return the value for the state data with that name.
Throws:
NONE
Side Effects:
Sets the global variable %HTML::Mason::Commands::session
Notes:
NONE
The set function takes a widget name, $widget, a state name, $state_name, and a hash ref, $state_data, containing state data. Both $state_name and $state_data are optional. If $state_name is undef, the state name will not be set, but if it does have a value it will be used to update the widget $widget state name. The same holds true for $state_data; undef will leave the state data untouched while a hash value will be used to overwrite the state data.
The get function returns both the state name and the state data..
Throws:
NONE
Side Effects:
Sets the global variable %HTML::Mason::Commands::session
Notes:
NONE
Completely clears the state information for the given widget.
Throws:
NONE
Side Effects:
Sets the global variable %HTML::Mason::Commands::session
Notes:
NONE
Get/set logged in user information.
Throws: NONE
Side Effects:
Uses Bric::App::Util::get_pref() and Bric::App::Util::set_pref().
Notes: NONE
NONE
Garth Webb <garth@perijove.com>