SYNOPSIS

  PerlSetVar  MasonRequestClass  MasonX::Request::WithMultiSession

DESCRIPTION

This module subclasses \*(C`MasonX::Request::WithApacheSession\*(C' in order to allow multiple \*(L"sub-sessions\*(R" to exist within one parent session.

This can be quite useful for a web app where you want to allow the user to open multiple windows, each with a different session, but session ids are stored in a cookie.

Like \*(C`MasonX::Request::WithApacheSession\*(C', sub-sessions are shared between a request and any subrequests it creates.

METHODS

This class has an interface quite similar to that of \*(C`MasonX::Request::WithApacheSession\*(C'.

  • session The primary interface to this class is through the \*(C`session()\*(C' method. When this method is called without any parameters, the module looks for an existing sub-session specified by the sub-session id argument parameter (which can be in a query string or \s-1POST\s0). This value can be overridden by explicitly passing a \*(L"sub_session_id\*(R" parameter. If this parameter is found, an existing sub-session is returned. If this parameter is not found, a new sub-session is created. If the \*(C`session()\*(C' method is called as \*(C`session( clone => 1 )\*(C' then a new sub-session will be created, and its contents will be the same as that of the current sub-session. This is a shallow copy of the old session hash, so objects and references are shared between them. If \*(C`session( new => 1 )\*(C' is called, then a new, empty, sub-session is created. You can specify the main session id to use via the \*(L"session_id\*(R" parameter.

  • sub_session_id This method returns the currently active sub-session's id. Use this method to put this id into \s-1URL\s0 parameters, forms, etc. as needed. If given a \*(L"sub_session_id\*(R" parameter, it will set the current sub-session id.

  • delete_sub_session By default, this simply defaults the current sub-session. You can pass a \*(L"sub_session_id\*(R" parameter to delete a specific session.

Parameters

This module takes two parameters besides those inherited from \*(C`MasonX::Request::WithApacheSession\*(C':

  • multi_session_args_param / MultiSessionArgsParam This parameter can be used to specify which parameter contains the sub-session id. By default, the module will look for a parameter called \*(L"sub_session_id\*(R".

  • multi_session_expire / MultiSessionExpire This parameter specifies the number of seconds after a sub-session is accessed until it is purged. If not specified, then sub-sessions are never purged. Sub-sessions expiration is checked when the request object goes out of scope.

USAGE

You will need to manually set the sub-session id argument parameter for each request. The easiest way to do this is to make sure that all URLs contain the sub-session id. This can be done by using a \*(C`<%filter>\*(C' block in a top-level autohandler (although this won't catch redirects), or by making sure all URLs are generated by a single component/function.

SUPPORT

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, <[email protected]>

Development funded by Marigold Technologies.

RELATED TO MasonX::Request::WithMultiSession…

HTML::Mason