DeltaX::Session - Perl module for session management
_____ / \ _____ ______ ______ ___________ / \ / \\__ \ / ___// ___// __ \_ __ \ / Y \/ __ \_\___ \ \___ \\ ___/| | \/ \____|__ (____ /____ >____ >\___ >__| \/ \/ \/ \/ \/ project
use DeltaX::Database; use DeltaX::Session; my $db = new DeltaX::Database(...); my $sess = new DeltaX::Session(db=>$db, table_name=>'my_sessions'); my $sid = '12345'; # Session ID $sess->put($sid, key1=>'data1', key2=>'data2'); if (!$sess->exist($sid)) { # some error } my %data = $sess->get($sid);
This module is prepared for session management (especially for masser applications). It can store session information in database table (preffered), shared memory or file (both in practise untested). Session is identified by SID - Session IDentification - some unique identifier composed from a-z, A-Z and 0-9 characters (for example md5_hex from Digest::MD5 is good for creating it). If you use database table, you must create table with this structure:
create table <name_as_you_want> ( sid varchar(32) not null, -- according to SID you will use sdata varchar(2000), -- as data you will store ts timestamp -- date & time primary key (sid) );
If you use shared memory, you must have IPC::SharedCache installed. WARNING: Not fully implemented.
If you use file, you must have module for selected storage type installed (default is GDBM_File).
There are no functions which allow you to modify or delete SID (because of performance issues).
Constructor. It uses parameters in key => value form:
Reference to initialized DeltaX::Database. If set, session data will be stored in this database.
If you are using database storage, this is a table name which will hold data (default is 'sessions').
Shared memory key (up to 4 characters - see IPC::SharedCache). If set, session data will be stored in shared memory with this key.
Shared memory segment size (only valid if shm_key set) - see IPC::SharedCache for explanation. Default is 10000 bytes.
Maximum shared memory size (only valid if shm_key set) - see IPC::SharedCache for explanation. Default is 1000000 bytes.
Timeout in seconds, after which will be record in cache invalidated (see IPC::SharedCache, validate_callback). Default is 300 seconds.
Filename of file in which session data will be stored.
Database file type to store session data, default is GDBM_File. Appropriate module must be installed.
This function allows you to put some data linked to given SID. The first parameter is SID, other parameters are in key => value form. Returned values:
Tests if given SID exists in storage, only one required parameter is SID. Returns true if SID exists, otherwise returns false (0).
Returns hash with values assigned to given SID (first and required parameter). Returns undef in case of error.
Frees resources used by module (especially closes opened statements if using database).
To install DeltaX::Page, copy and paste the appropriate command in to your terminal.
cpanm
cpanm DeltaX::Page
CPAN shell
perl -MCPAN -e shell install DeltaX::Page
For more information on module installation, please visit the detailed CPAN module installation guide.