MasonX...Session(3pm)
π MasonX::Request::WithMultiSession β a.k.a. MasonX...Session(3pm) π
User Contributed Perl Documentation β¨ welcome to the cutest corner of the Perl docs, bestie. This one lives in the 3pm manual and it's all about having a whole little family of sessions under one parent session. Obsessed, honestly. π«Ά
β¨ NAME β¨
MasonX::Request::WithMultiSession β multiple sub-sessions within one "parent" session πΈ
π SYNOPSIS π
PerlSetVar MasonRequestClass MasonX::Request::WithMultiSession
That's literally it, that's the whole setup. One PerlSetVar and you're in. Slay. π
π¦ DESCRIPTION π¦
So this module subclasses MasonX::Request::WithApacheSession specifically so you can have multiple "sub-sessions" hanging out inside one parent session. Like a group chat inside a group chat. Iconic.
Why would you even want that? Bestie, imagine a web app where you want the user to open a bunch of windows, each one with its own different session β but the session ids are stored in a cookie. Cookies don't know about your windows. Cookies are just one single vibe. So sub-sessions come in clutch. π₯
Same as MasonX::Request::WithApacheSession, sub-sessions get shared between a request and any subrequests it creates. So they travel together, no cap. π
π METHODS π
The interface here is quite similar to MasonX::Request::WithApacheSession's. Basically the same energy, but with a little extra.
sessionβ this is the main character, the primary interface to the whole class. When you call this method with no parameters at all, the module goes looking for an existing sub-session using the sub-session id argument parameter (which can be chillin' in a query string or in a POST). And you can totally override that value by explicitly passing asub_session_idparameter. π
If that parameter is found, you get an existing sub-session back. If it's not found? A brand new sub-session gets created for you. Fresh out the box. β¨
Now, if you call session() as session( clone => 1 ), then a new sub-session gets created and its contents will be the same as the current sub-session's. Heads up though β it's a shallow copy of the old session hash, so objects and references are shared between them. Not a deep clone, bestie. Don't get it twisted. π
And if you call session( new => 1 ), you get a new, empty sub-session. Blank slate, clean girl aesthetic. π§
Oh and you can specify the main session id you want to use via the session_id parameter. π
sub_session_idβ returns the id of the currently active sub-session. Use this to drop that id into URL parameters, forms, etc., wherever you need it. If you give it asub_session_idparameter, it'll set the current sub-session id. Simple as. π«Άdelete_sub_sessionβ by default, this just, um, "defaults" the current sub-session (that's literally what the docs say, bestie, I'm just the messenger π). You can pass asub_session_idparameter to delete a specific session instead. ποΈ
πΈ Parameters πΈ
This module takes two parameters on top of everything it inherits from MasonX::Request::WithApacheSession:
multi_session_args_param/MultiSessionArgsParamβ use this to say which parameter holds the sub-session id. By default, the module goes looking for a parameter namedsub_session_id. πmulti_session_expire/MultiSessionExpireβ this one sets the number of seconds after a sub-session is accessed until it gets purged. If you don't specify it, then sub-sessions are never purged. They just live forever, immortal little guys. β
Quick thing though: sub-session expiration is checked when the request object goes out of scope. So that's when the timer actually gets consulted. π
π USAGE π
You will need to manually set the sub-session id argument parameter for each request. Yeah, manually. Sorry bestie, it's giving DIY. π
The easiest way is to make sure all your URLs contain the sub-session id. Two ways to pull that off:
- Use a
<%filter>block in a top-level autohandler β though heads up, this won't catch redirects. π - Or just make sure all your URLs are generated by a single component/function. Centralized, organized, very mindful, very demure. β¨
π SUPPORT π
Got bugs? Need help? Send it all to the mason-users list. More deets live at http://www.masonhq.com/resources/mailing_lists.html. They're nice, go say hi. π«Ά
π AUTHOR π
Dave Rolsky, <autarch@urth.org>
Development funded by Marigold Technologies. Shoutout to them, real ones. πΈ
π₯ SEE ALSO π₯
HTML::Mason
And that's the whole page, bestie β this one's from perl v5.36.0, dated 2022-10-13. Go forth and multiply your sessions. π
β¨π¦
π¦ 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