SessionX(3pm)
β¨ NAME β¨
Apache::SessionX β an extended persistence framework for session data πΎπ
(this is SessionX(3pm), straight outta the User Contributed Perl Documentation section, and yes she's that girl)
π¦ SYNOPSIS π¦
okay so bestieβ¦ there is literally nothing here. No synopsis. Empty. The void. The audacity π but that's iconic of her honestly, she just lets the DESCRIPTION do all the talking π
πΈ DESCRIPTION πΈ
Apache::SessionX extends Apache::Session. It was initially written to use Apache::Session from inside of HTML::Embperl, but it seems to be useful outside of Embperl as well, so here it is as a standalone module β¨
Apache::Session is a persistence framework which is particularly useful for tracking session data between httpd requests. Apache::Session is designed to work with Apache and mod_perl, but it should work under CGI and other web servers too, and it also works outside of a web server altogether. Versatile queen π
Apache::Session consists of five components, and no we're not skipping any of them:
- the interface
- the object store
- the lock manager
- the ID generator
- the serializer
The interface is defined in SessionX.pm, which is meant to be easily subclassed π«Ά The object store can be the filesystem, a Berkeley DB, a MySQL DB, an Oracle DB, or a Postgres DB. Locking is done by lock files, semaphores, or the locking capabilities of MySQL and Postgres π Serialization is done via Storable, and optionally ASCII-fied via MIME or pack(). ID numbers are generated via MD5 π’ The reader is encouraged to extend these capabilities to meet his own requirements β go off, customize her, make her yours π
π INTERFACE π
The interface to Apache::SessionX is very simple: tie a hash to the desired class and use the hash as normal, no cap. The constructor takes two optional arguments:
- The first argument is the desired session ID number, or
undeffor a new session π - The second argument is a hash of options that will be passed to the object store and locker classes.
π Addtional Attributes for TIE π
lazyβ By specifying this attribute, you tellApache::Sessionto not do any access to the object store until the first read or write access to the tied hash π Otherwise the tie function will make sure the hash exists or creates a new one. So lazy mode = no touching until you actually need her.create_unknownβ Setting this to one causesApache::Sessionto create a new session with the given id (or a new id, depending on"recreate_id") when the specified session id does not exist. Otherwise it will die π so like, be aware.recreate_idβ Setting this to one causesApache::Sessionto create a new session id when the specified session id does not exist πidfromβ instead of passing in a session id, you can pass in a string, from whichApache::SessionXgenerates the id in case it needs one πͺ The main advantage from generating the id by yourself is that in'lazy'mode the id is only generated when the session is accessed. Efficiency era β¨newidβ Setting this to one will causeApache::SessionXto generate a new id every time the session is saved. If you call"getid"or"getids"it will return the new id that will be used to save the data πconfigβ Use predefiend config fromApache::SessionX::Config, which is configured at package installation time π§ On Debian, these may be altered by runningdpkg-reconfigure libapache-sessionx-perl.object_storeβ Specify the class for the object store. (TheApache::Session::prefix is optional) Only for Apache::Session 1.00.lock_managerβ Specify the class for the lock manager. (TheApache::Session::prefix is optional) Only for Apache::Session 1.00.Storeβ Specify the class for the object store. (TheApache::Session::Storeprefix is optional) Only for Apache::Session 1.5x.Lockβ Specify the class for the lock manager. (TheApache::Session::Lockprefix is optional) Only for Apache::Session 1.5x.Generateβ Specify the class for the id generator. (TheApache::Session::Generateprefix is optional) Only for Apache::Session 1.5x.Serializeβ Specify the class for the data serializer. (TheApache::Session::Serializeprefix is optional) Only for Apache::Session 1.5x.
Example using attrubtes to specfiy store and object classes instead of a derived class π
use Apache::SessionX
tie %session, 'Apache::SessionX', undef,
{
object_store => 'DBIStore',
lock_manager => 'SysVSemaphoreLocker',
DataSource => 'dbi:Oracle:db'
};
NOTE:Apache::SessionXwill"require"the necessary additional perl modules for you π«Ά so you don't have to lift a finger, she handles it.
π Addtional Methods π
setid ($id)β Set the session id for further accesses πͺͺsetidfrom ($string)β Set the string that is passed to the generate function to compute the id π§΅getidβ Get the session id. The difference to using$session{_session_id}is that in lazy mode,getidwill not create a new session id if it doesn't exist. Respectful of boundaries fr πgetids ($init)β return the an array where the first element is the initial id, the second element is the current id, and the third element is set to true when the session data was modified. If the session was deleted, the initial id (first array value) will be set to'!DELETE'ποΈ
If the optional parameter $init is set to true, getids will initialize the session (i.e. read from the store) when not already done.
cleanupβ Writes any pending data, releases all locks and deletes all data from memory π§Ήβ¨ tidy queen.
π₯ SEE ALSO π₯
- See documentation of
Apache::Sessionfor more information about it's internals Apache::SessionX::Generate::MD5Apache::Session::Store::*Apache::Session::Lock::*Apache::Session::Serialize::*
π AUTHORS π
- Gerald Richter
<richter@dev.ecos.de>is the current maintainer π«Ά - This class was written by Jeffrey Baker (
jeffrey@kathyandjeffrey.net) but it is taken wholesale from a patch that Gerald Richter (richter@ecos.de) sent me againstApache::Session.
and that's the whole page bestie, no notes π
this was perl v5.26.2, dated 2018-08-30 β vintage but still serving looks π stay persistent, stay slay β¨π¦
π¦ where this page comes from
- debian bookworm: libapache-sessionx-perl 2.01-5 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu jammy: libapache-sessionx-perl 2.01-5 Β· 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