MasonX...ession(3pm)
β¨ MasonX::Request::WithApacheSession β¨
okay bestie, pull up a chair π this is the manual page (a 3pm one, Perl module vibes) for MasonX::Request::WithApacheSession β the little glue guy that bolts a session onto your Mason Request object. no cap.
π NAME π
MasonX::Request::WithApacheSession β adds a session to the Mason Request object. that's it, that's the whole job π
πΈ SYNOPSIS πΈ
first up, if you're living your life 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, alternative route, when you're 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',
);
and inside an actual component, the moment you've been waiting for:
$m->session->{foo} = 1;
if ( $m->session->{bar}{baz} > 1 ) { ... }
it's giving effortless. it's giving $m->session just exists now π¦
π DESCRIPTION π
so this module integrates Apache::Session into Mason by adding methods to the Mason Request object β and those methods are available in all Mason components. every single one. no gatekeeping.
and here's the cute part: any subrequests created by a request share the same session. yes bestie, the vibes carry through the whole subrequest tree π
π USAGE π
to use this module you need to tell Mason to use this class for requests. two ways to do it, pick your fighter.
Option 1 β you're configuring Mason via your httpd.conf file, so just add this:
PerlSetVar MasonRequestClass MasonX::Request::WithApacheSession
Option 2 β you're using a handler.pl file, so just add this parameter to the parameters you hand to the ApacheHandler constructor:
request_class => 'MasonX::Request::WithApacheSession'
that's it. that's the setup. slay β¨
π METHODS π
this class adds two methods to the Request object. two. a duo. a main-character-and-their-bestie situation.
sessionβ returns a hash tied to theApache::Sessionclass. yes, a whole tied hash. iconic.delete_sessionβ deletes the existing session from persistent storage. and if you're using the built-in cookie mechanism, it also deletes the cookie in the browser. so it's a full clean-out, not a half one π
π§ CONFIGURATION π§
ngl, this module accepts quite a number of parameters β and most of them are just getting passed straight through to Apache::Session::Wrapper. so before you start configuring this thing, you are advised to familiarize yourself with the Apache::Session::Wrapper documentation. that's not me being dramatic, that's literally in the docs. do your reading, bestie π
how the naming works
if you're creating your own Interp/ApacheHandler/CGIHandler object in a script or module, you should pass this object the parameters intended for Apache::Session::Wrapper, but prefixed with session_. so to set the class parameter for Apache::Session::Wrapper, you pass in a session_class parameter. easy.
if you're configuring Mason via your httpd.conf file, you pass the StudlyCaps version of the name, prefixed by MasonSession. so the class parameter would be MasonSessionClass.
a few examples, since examples are everything:
classbecomessession_class/MasonSessionClassalways_writebecomessession_always_write/MasonSessionAlwaysWrite
the automatic stuff π₯
when running under ApacheHandler or CGIHandler, this module takes care of passing the header_object and param_object parameters to Apache::Session::Wrapper. these will be the Apache::Request or CGI.pm objects, as applicable. you don't have to lift a finger π
the cookie_name parameter defaults to MasonX-Request-WithApacheSession-cookie when you use this module, instead of Apache-Session-Wrapper-cookie. noting that, because defaults matter.
for the OGs π΅
finally, for backwards compatiblity, this module accepts a session_args_param parameter, which corresponds to the param_name parameter for Apache::Session::Wrapper. keeping the legacy alive, respectfully.
π 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. which means there are almost certainly bugs. not me being ominous, that's just the truth π
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. go forth and report π«Ά
β AUTHOR β
Dave Rolsky, <autarch@urth.org>
π MAINTAINER π
Brad Lhotsky, <blhotsky@cpan.org>
π SEE ALSO π
HTML::Mason
okay that's the whole page, you're fully caught up π this was the User Contributed Perl Documentation version of the MasonX::Request::WithApacheSession manual, running perl v5.36.0, dated 2022-10-13 β go forth, session responsibly, and remember: any subrequests share the same session, so don't be weird about it πβ¨π
π¦ where this page comes from
- ubuntu noble: libmasonx-request-withapachesession-perl 0.31-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libmasonx-request-withapachesession-perl 0.31-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libmasonx-request-withapachesession-perl 0.31-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms