CGI::MxScreen::Session::Medium::File - File session medium
# Not meant to be used directly
This saves the session within a file on the server side. Session files are created under a set of directories, to avoid having directories with two many files in them, which is inefficient on most filesystems (reiserfs excepted). An MD5 hash of the session ID is taken to compute two sub directories, resulting in session files being stored as:
W/N/192.168.0.3-987001261-28947 k/5/192.168.0.3-987177890-16666
You can see the pattern used for session ids: the IP address of the client making the request, a timestamp indicating the start of the session, and the PID of the process. However, this is used only when the targetted session ID is free, otherwise, a random cryptic session ID is generated.
Because sessions will use disk space, you need an expiration policy. If someone attempts to continue a session that has been removed, CGI::MxScreen will return an error, and that someone will have to restart the whole session, thereby potentially loosing all the work already done.
CGI::MxScreen
On my web server, I use the following command to expire sessions after a week of inactivity:
cd /var/tmp/web-sessions find . -type f -atime +7 | xargs rm -f
The creation routine takes the following arguments:
-directory
Mandatory argument, giving the root directory where sessions are saved.
-max_hold
Optional argument, defining the timeout after which a lock is declared stale. Defaults is 60 seconds.
-nfs
Optional, tells whether session files are read from a local or a network filesystem (e.g. NFS). Assumes local filesystem by default.
You can configure this session medium in the configuration file as explained in CGI::MxScreen::Config by saying:
$mx_medium = ["+File", -directory => "/var/tmp/www-sessions"];
You can further say:
$mx_serializer = ["+Storable", -compress => 1];
to store sessions in compressed forms, although I advise you not to, for performance reasons. Actually, you should look at CGI::MxScreen::Session::Medium::Raw_File if you want fast session files.
Raphael Manfredi <Raphael_Manfredi@pobox.com>
CGI::MxScreen::Session::Medium::Browser(3), CGI::MxScreen::Session::Medium::Raw_File(3).
To install CGI::MxScreen, copy and paste the appropriate command in to your terminal.
cpanm
cpanm CGI::MxScreen
CPAN shell
perl -MCPAN -e shell install CGI::MxScreen
For more information on module installation, please visit the detailed CPAN module installation guide.