MasonX::Request::WithApacheSession |
NAME ![]() |
MasonX::Request::WithApacheSession - Add a session to the Mason Request object
SYNOPSIS ![]() |
![]() |
In your httpd.conf file:
PerlSetVar MasonRequestClass MasonX::Request::WithApacheSession PerlSetVar MasonSessionCookieDomain .example.com PerlSetVar MasonSessionClass Apache::Session::File PerlSetVar MasonSessionDirectory /tmp/sessions/data PerlSetVar MasonSessionLockDirectory /tmp/sessions/locks
Or when creating an ApacheHandler object:
my $ah = HTML::Mason::ApacheHandler->new ( request_class => 'MasonX::Request::WithApacheSession', session_cookie_domain => '.example.com', session_class => 'Apache::Session::File', session_directory => '/tmp/sessions/data', session_lock_directory => '/tmp/sessions/locks', );
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.
Any subrequests created by a request share the same session.
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 MasonX::Request::WithApacheSession
If you are using a handler.pl file, simply add this parameter to the parameters given to the ApacheHandler constructor:
request_class => 'MasonX::Request::WithApacheSession'
METHODS ![]() |
![]() |
This class adds two methods to the Request object.
Apache::Session
class.
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 this module.
Generic Parameters ![]() |
![]() |
Apache::Session
subclass you would like to use.
This module will load this class for you if necessary.
This parameter is required.
Apache::Session
writes the session. If it is false, the default Apache::Session
behavior is used instead.
This defaults to true.
HTML::Mason::Exception::NonExistentSessionID
exception will be
thrown instead.
This defaults to true.
Cookie-Related Parameters ![]() |
![]() |
Apache::Cookie
to set and read
cookies that contain the session id.
The cookie will be set again every time the client accesses a Mason
component unless the session_cookie_resend
parameter is false.
Apache::Cookie
``-name'' constructor parameter.
If it is undefined, then no ``-domain'' parameter will be given.
URL-Related Parameters ![]() |
![]() |
If you are also using cookies, then the module checks in the request arguments first, and then it checks for a cookie.
The session id is available from $m->session->{_session_id}
.
Apache::Session-related Parameters ![]() |
![]() |
These parameters are simply passed through to Apache::Session
.
DataSource
parameter given to the DBI-related
session modules.
UserName
parameter given to the DBI-related
session modules.
Password
parameter given to the DBI-related
session modules.
Handle
parameter given to the DBI-related
session modules. This cannot be set via the httpd.conf file,
because it needs to be an actual Perl variable, not the name of
that variable.
LockDataSource
parameter given to
Apache::Session::MySQL
.
LockUserName
parameter given to
Apache::Session::MySQL
.
LockPassword
parameter given to
Apache::Session::MySQL
.
LockHandle
parameter given to the DBI-related
session modules. As with the session_handle
parameter, this cannot
be set via the httpd.conf file.
Commit
parameter given to the DBI-related
session modules.
Transaction
parameter.
Directory
parameter given to
Apache::Session::File
.
LockDirectory
parameter given to
Apache::Session::File
.
FileName
parameter given to
Apache::Session::DB_File
.
Store
parameter given to
Apache::Session::Flex
.
Lock
parameter given to
Apache::Session::Flex
.
Generate
parameter given to
Apache::Session::Flex
.
Serialize
parameter given to
Apache::Session::Flex
.
textsize
parameter given to
Apache::Session::Sybase
.
LongReadLen
parameter given to
Apache::Session::MySQL
.
NSems
parameter given to
Apache::Session::Lock::Semaphore
.
SemaphoreKey
parameter given to
Apache::Session::Lock::Semaphore
.
ModUsertrackCookieName
parameter given to
Apache::Session::Generate::ModUsertrack
.
SavePath
parameter given to
Apache::Session::PHP
.
HOW COOKIES ARE HANDLED ![]() |
![]() |
When run under the ApacheHandler module, this module attempts to first
use Apache::Cookie
for cookie-handling. Otherwise it uses
CGI::Cookie
as a fallback.
If it ends up using CGI::Cookie
then it can only set cookies if it
is running under either the ApacheHandler or the CGIHandler module.
Otherwise, the MasonX::Request::WithApacheSession
request object
has no way to get to an object which can take the headers. In other
words, if there's no $r
, there's nothing with which to set headers.
SUPPORT ![]() |
![]() |
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.
Bug reports and requests for help should be sent to the mason-users list. See http://www.masonhq.com/resources/mailing_lists.html for more details.
AUTHOR ![]() |
![]() |
Dave Rolsky, <autarch@urth.org>
SEE ALSO ![]() |
![]() |
HTML::Mason
MasonX::Request::WithApacheSession |