1MasonX::Request::WithApUascehreSCeosnstiroinb(u3t)ed PerMlasDooncXu:m:eRnetqauteisotn::WithApacheSession(3)
2
3
4
6 MasonX::Request::WithApacheSession - Add a session to the Mason Request
7 object
8
10 In your httpd.conf file:
11
12 PerlSetVar MasonRequestClass MasonX::Request::WithApacheSession
13 PerlSetVar MasonSessionCookieDomain .example.com
14 PerlSetVar MasonSessionClass Apache::Session::File
15 PerlSetVar MasonSessionDirectory /tmp/sessions/data
16 PerlSetVar MasonSessionLockDirectory /tmp/sessions/locks
17
18 Or when creating an ApacheHandler object:
19
20 my $ah =
21 HTML::Mason::ApacheHandler->new
22 ( request_class => 'MasonX::Request::WithApacheSession',
23 session_cookie_domain => '.example.com',
24 session_class => 'Apache::Session::File',
25 session_directory => '/tmp/sessions/data',
26 session_lock_directory => '/tmp/sessions/locks',
27 );
28
29 In a component:
30
31 $m->session->{foo} = 1;
32 if ( $m->session->{bar}{baz} > 1 ) { ... }
33
35 This module integrates "Apache::Session" into Mason by adding methods
36 to the Mason Request object available in all Mason components.
37
38 Any subrequests created by a request share the same session.
39
41 To use this module you need to tell Mason to use this class for
42 requests. This can be done in one of two ways. If you are configuring
43 Mason via your httpd.conf file, simply add this:
44
45 PerlSetVar MasonRequestClass MasonX::Request::WithApacheSession
46
47 If you are using a handler.pl file, simply add this parameter to the
48 parameters given to the ApacheHandler constructor:
49
50 request_class => 'MasonX::Request::WithApacheSession'
51
53 This class adds two methods to the Request object.
54
55 • session
56
57 This method returns a hash tied to the "Apache::Session" class.
58
59 • delete_session
60
61 This method deletes the existing session from persistent storage.
62 If you are using the built-in cookie mechanism, it also deletes the
63 cookie in the browser.
64
66 This module accepts quite a number of parameters, most of which are
67 simply passed through to "Apache::Session::Wrapper". For this reason,
68 you are advised to familiarize yourself with the
69 "Apache::Session::Wrapper" documentation before attempting to configure
70 this module.
71
72 If you are creating your own Interp/ApacheHandler/CGIHandler object in
73 a script or module, you should pass this object the parameters intended
74 for "Apache::Session::Wrapper", prefixed with "session_". So to set
75 the "class" parameter for "Apache::Session::Wrapper", you pass in a
76 "session_class" parameter.
77
78 If you are configuring Mason via your httpd.conf file, you should pass
79 the "StudlyCaps" version of the name, prefixed by "MasonSession". So
80 the "class" parameter would be "MasonSessionClass".
81
82 A few examples:
83
84 • class becomes session_class / MasonSessionClass
85
86 • always_write becomes session_always_write / MasonSessionAlwaysWrite
87
88 When running under ApacheHandler or CGIHandler, this module takes care
89 of passing the "header_object" and "param_object" parameters to
90 "Apache::Session::Wrapper". These will be the "Apache::Request" or
91 "CGI.pm" objects, as applicable.
92
93 The "cookie_name" parameter defaults to "MasonX-Request-
94 WithApacheSession-cookie" when you use this module, instead of "Apache-
95 Session-Wrapper-cookie".
96
97 Finally, for backwards compatiblity, this module accepts a
98 "session_args_param" parameter, which corresponds to the "param_name"
99 parameter for "Apache::Session::Wrapper".
100
102 As can be seen by the number of parameters above, "Apache::Session" has
103 way too many possibilities for me to test all of them. This means
104 there are almost certainly bugs.
105
106 Bug reports and requests for help should be sent to the mason-users
107 list. See http://www.masonhq.com/resources/mailing_lists.html for more
108 details.
109
111 Dave Rolsky, <autarch@urth.org>
112
114 Brad Lhotsky, <blhotsky@cpan.org>
115
117 HTML::Mason
118
119
120
121perl v5.32.1 2021-01-M2a7sonX::Request::WithApacheSession(3)