man Bric::App::Session () - A class to handle user sessions

NAME

Bric::App::Session - A class to handle user sessions

VERSION

$LastChangedRevision$

DATE

$LastChangedDate: 2004-08-12 17:13:34 -0700 (Thu, 12 Aug 2004) $

SYNOPSIS

  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);

DESCRIPTION

This module provides all the necessary functions for maintaining state within widgets. This includes setting a global state variable CW$session as well as accessor methods for setting the state name of a widget and state data of a widget.

INTERFACE

Public Class Methods

instance()
Return a reference to the CW%session hash so that other parts of the API can get the current session without using CW%HTML::Mason::Commands::session directly. Throws: NONE Side Effects: NONE Notes: NONE

#------------------------------------------------------------------------------#

Functions

setup_user_session($r)
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
sync_user_session()
Synchronizes changes to the user session back to the file system. Throws:
*
Unable to synchronize user session. Side Effects:
*
Unties the global variable CW%HTML::Mason::Commands::session. Notes: NONE
expire_session()
Expires the user session, deleting it from the disk. Throws:
*
Unable to expire user session. Side Effects:
*
Deletes the global CW%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 CW%HTML::Mason::Commands::session Notes: NONE
$state_name = get_state_name($widget)
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 CW%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 CW%HTML::Mason::Commands::session Notes: NONE The set function takes a widget name, CW$widget, a state name, CW$state_name, and a hash ref, CW$state_data, containing state data. Both CW$state_name and CW$state_data are optional. If CW$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 CW$widget state name. The same holds true for CW$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 CW%HTML::Mason::Commands::session Notes: NONE
clear_state($widget)
Completely clears the state information for the given widget. Throws: NONE Side Effects:
*
Sets the global variable CW%HTML::Mason::Commands::session Notes: NONE
(0 || 1) = set_user($user);
($login || undef) = get_user_login;
($uid || undef) = get_user_id;
($user || undef) = get_user_object;
Get/set logged in user information. Throws: NONE Side Effects:
*
Uses Bric::App::Util::get_pref() and Bric::App::Util::set_pref(). Notes: NONE

NOTES

NONE

AUTHOR

Garth Webb <garth@perijove.com>

SEE ALSO

perl, Bric, Apache::Session::File