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


MasonX-Request-WithApacheSession2 documentation  | view source Contained in the MasonX-Request-WithApacheSession2 distribution.

Index


NAME

Top

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

SYNOPSIS

Top

In your httpd.conf file:

  PerlSetVar  MasonRequestClass         MasonX::Request::WithApacheSession2
  PerlSetVar  MasonSessionCookieDomain  .example.com
  PerlSetVar  MasonSessionClass         Apache::Session::MySQL
  PerlSetVar  MasonSessionDataSource    dbi:mysql:somedb

Or when creating an ApacheHandler2 object:

  my $ah =
      HTML::Mason::ApacheHandler2->new
          ( request_class => 'MasonX::Request::WithApacheSession2',
            session_cookie_domain => '.example.com',
            session_class         => 'Apache::Session2::MySQL',
            session_data_source   => 'dbi:mysql:somedb',
          );

In a component:

  $m->session->{foo} = 1;
  if ( $m->session->{bar}{baz} > 1 ) { ... }

DESCRIPTION

Top

MasonX::Request::WithApacheSession2 is highly experimental ( alpha ) and should only be used in a test environment.

MasonX::Request::WithApacheSession2 is a clone of MasonX::Request::WithApacheSession changed to work under a pure mod_perl2 environment. The external interface is unchanged, see MasonX::Request::WithApacheSession.

The actual changes I made can be found in the distribution in diff/WithApacheSession.diff ( made with 'diff -Naru' ... ).

A HOWTO for HTML::Mason::ApacheHandler2 and friends may be found at Mason-with-mod_perl2.

The following documentation is from MasonX::Request::WithApacheSession,

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

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::WithApacheSession2

If you are using a handler.pl file, simply add this parameter to the parameters given to the ApacheHandler constructor:

  request_class => 'MasonX::Request::WithApacheSession2'

METHODS

Top

This class adds two methods to the Request object.

* session

This method returns a hash tied to the Apache::Session class.

* delete_session

This method deletes the existing session from persistent storage. If you are using the built-in cookie mechanism, it also deletes the cookie in the browser.

CONFIGURATION

Top

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

* session_class / MasonSessionClass => class name

The name of the Apache::Session subclass 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::Session writes the session. If it is false, the default Apache::Session behavior 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::NonExistentSessionID exception will be thrown instead.

This defaults to true.

HOW COOKIES ARE HANDLED

Top

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

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

Beau E. Cox <mason@beaucox.com> http://beaucox.com.

The real authors (I just made mod_perl2 changes) is Dave Rolsky, <autarch@urth.org>

Version 0.01 as of January, 2004.

SEE ALSO

Top

My documents, including: HOWTO Run Mason with mod_perl2 (Mason-with-mod_perl2), HTML::Mason::ApacheHandler2 (ApacheHandler2), MasonX::Request::WithMultiSession2 (WithMultiSession2),

Original Mason documents, including: HTML::Mason::ApacheHandler (ApacheHandler), MasonX::Request::WithApacheSession (WithApacheSession), MasonX::Request::WithMultiSession (WithMultiSession).

Also see the Mason documentation at http://masonhq.com/docs/manual/.


MasonX-Request-WithApacheSession2 documentation  | view source Contained in the MasonX-Request-WithApacheSession2 distribution.