MasonX::Request::WithApacheSession

NAME  top

MasonX::Request::WithApacheSession - Add a session to the Mason Request object

SYNOPSIS  top top  NAME

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  top top  SYNOPSIS

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  top top  DESCRIPTION

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  top top  USAGE

This class adds two methods to the Request object.

CONFIGURATION  top top  METHODS

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  top top  CONFIGURATION

Cookie-Related Parameters  top top  CONFIGURATION

URL-Related Parameters  top top  CONFIGURATION

Apache::Session-related Parameters  top top  CONFIGURATION

These parameters are simply passed through to Apache::Session.

HOW COOKIES ARE HANDLED  top top  CONFIGURATION

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  top top  HOW COOKIES ARE HANDLED

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  top top  SUPPORT

Dave Rolsky, <autarch@urth.org>

SEE ALSO  top top  AUTHOR

HTML::Mason

MasonX::Request::WithApacheSession