NAME
HTML::Mason::Request::WithApacheSession - Add a session to the Mason Request object
SYNOPSIS
In your httpd.conf file:
PerlSetVar MasonRequestClass HTML::Mason::Request::WithApacheSession
PerlSetVar MasonSessionCookieDomain .example.com
PerlSetVar MasonSessionClass Apache::Session::MySQL
PerlSetVar MasonSessionDataSource dbi:mysql:somedb
In a component:
$m->session->{foo} = 1;
if ( $m->session->{bar}{baz} > 1 ) { ... }
DESCRIPTION
This module integrates Apache::Session into Mason by adding methods to the Mason Request object available in all Mason components.
USAGE
To use this module you need to tell Mason to use this class for requests. This can be done in one of two ways. If you are configuring Mason via your httpd.conf file, simply add this:
PerlSetVar MasonRequestClass HTML::Mason::Request::WithApacheSession
If you are using a handler.pl file, simply add this parameter to the parameters given to the ApacheHandler constructor:
request_class => 'HTML::Mason::Request::WithApacheSession'
CONFIGURATION
This module accepts quite a number of parameters, most of which are simply passed through to Apache::Session. For this reason, you are advised to familiarize yourself with the Apache::Session documentation before attempting to configure tihs module.
Generic Parameters
session_class / MasonSessionClass => class name
The name of the
Apache::Sessionsubclass you would like to use.This module will load this class for you if necessary.
This parameter is required.
session_always_write / MasonSessionAlwaysWrite => boolean
If this is true, then this module will ensure that
Apache::Sessionwrites the session. If it is false, the defaultApache::Sessionbehavior is used instead.This defaults to true.
session_allow_invalid_id / MasonSessionAllowInvalidId => boolean
If this is true, an attempt to create a session with a session id that does not exist in the session storage will be ignored, and a new session will be created instead. If it is false, a
HTML::Mason::Exception::NonExistentSessionIDexception will be thrown instead.This defaults to true.
Cookie-Related Parameters
session_use_cookie / MasonSessionUseCookie => boolean
If true, then this module will use
Apache::Cookieto set and read cookies that contain the session id.The cookie will be set again every time the client accesses a Mason component.
session_cookie_name / MasonSessionCookieName => name
This is the name of the cookie that this module will set. This defaults to "HTML-Mason-Request-WithApacheSession-cookie". Corresponds to the
Apache::Cookie"-name" constructor parameter.session_cookie_expires / MasonSessionCookieExpires => expiration
How long before the cookie expires. This defaults to 1 day, "+1d". Corresponds to the "-expires" parameter.
session_cookie_domain / MasonSessionCookieDomain => domain
This corresponds to the "-domain" parameter. If not given this will not be set as part of the cookie.
session_cookie_path / MasonSessionCookiePath => path
Corresponds to the "-path" parameter. It defaults to "/".
session_cookie_secure / MasonSessionCookieSecure => boolean
Corresponds to the "-secure" parameter. It defaults to false.
Apache::Session-related Parameters
These parameters are simply passed through to Apache::Session.
session_data_source / MasonSessionDataSource => DSN
Corresponds to the
DataSourceparameter given to the DBI-related session modules.session_user_name / MasonSessionUserName => user name
Corresponds to the
UserNameparameter given to the DBI-related session modules.session_password / MasonSessionPassword => password
Corresponds to the
Passwordparameter given to the DBI-related session modules.session_handle / MasonSessionHandle => DBI handle
Corresponds to the
Handleparameter given to the DBI-related session modules.session_lock_data_source / MasonSessionLockDataSource => DSN
Corresponds to the
LockDataSourceparameter given toApache::Session::MySQL.session_lock_user_name / MasonSessionLockUserName => user name
Corresponds to the
LockUserNameparameter given toApache::Session::MySQL.session_lock_password / MasonSessionLockPassword => password
Corresponds to the
LockPasswordparameter given toApache::Session::MySQL.session_lock_handle / MasonSessionLockHandle => DBI handle
Corresponds to the
LockHandleparameter given to the DBI-related session modules.session_commit / MasonSessionCommit => boolean
Corresponds to the
Commitparameter given to the DBI-related session modules.session_transaction / MasonSessionTransaction => boolean
Corresponds to the
Transactionparameter.session_directory / MasonSessionDirectory => directory
Corresponds to the
Directoryparameter given toApache::Session::File.session_lock_directory / MasonSessionLockDirectory => directory
Corresponds to the
LockDirectoryparameter given toApache::Session::File.session_file_name / MasonSessionFileName => file name
Corresponds to the
FileNameparameter given toApache::Session::DB_File.session_store / MasonSessionStore => class
Corresponds to the
Storeparameter given toApache::Session::Flex.session_lock / MasonSessionLock => class
Corresponds to the
Lockparameter given toApache::Session::Flex.session_generate / MasonSessionGenerate => class
Corresponds to the
Generateparameter given toApache::Session::Flex.session_serialize / MasonSessionSerialize => class
Corresponds to the
Serializeparameter given toApache::Session::Flex.session_textsize / MasonSessionTextsize => size
Corresponds to the
textsizeparameter given toApache::Session::Sybase.session_long_read_len / MasonSessionLongReadLen => size
Corresponds to the
LongReadLenparameter given toApache::Session::MySQL.session_n_sems / MasonSessionNSems => number
Corresponds to the
NSemsparameter given toApache::Session::Lock::Semaphore.session_semaphore_key / MasonSessionSemaphoreKey => key
Corresponds to the
SemaphoreKeyparameter given toApache::Session::Lock::Semaphore.session_mod_usertrack_cookie_name / MasonSessionModUsertrackCookieName => name
Corresponds to the
ModUsertrackCookieNameparameter given toApache::Session::Generate::ModUsertrack.session_save_path / MasonSessionSavePath => path
Corresponds to the
ModSavePathparameter given toApache::Session::PHP.
BUGS
As can be seen by the number of parameters above, Apache::Session has way too many possibilities for me to test all of them. This means there are almost certainly bugs.
AUTHOR
Dave Rolsky, <autarch@urth.org>
SEE ALSO
HTML::Mason