NAME
Concierge::Sessions::Base - Base class for session storage backends
VERSION
version 0.8.5
SYNOPSIS
# This is a base class - do not use directly
# Backend implementations inherit from this class:
package Concierge::Sessions::MyBackend;
use parent 'Concierge::Sessions::Base';
sub create_session {
my ($self, %args) = @_;
# Implementation...
}
# Implement other required methods...
DESCRIPTION
Concierge::Sessions::Base is a base class that defines the interface for session storage backends. Backend implementations (SQLite, File) inherit from this class and must implement the defined methods.
This class also provides utility methods such as generate_session_id().
Users typically do not interact with this class directly - they use Concierge::Sessions which manages backend objects internally.
REQUIRED METHODS
Backend implementations must implement the following methods:
create_session
Creates a new session in the backend storage.
my $result = $backend->create_session(
user_id => 'user123',
session_timeout => 3600,
data => \%session_data,
);
Must return:
{
success => 1,
session_id => 'hex-string',
}
get_session_info
Retrieves session information from backend storage.
my $result = $backend->get_session_info($session_id);
Must return:
{
success => 1,
info => {
session_id => 'hex-string',
user_id => 'user123',
session_timeout => 3600,
data => \%data,
created_at => $timestamp,
expires_at => $timestamp,
last_updated => $timestamp,
status => { state => 'active', dirty => 0 },
},
}
Or on error:
{
success => 0,
message => "Error description",
}
update_session
Updates session data and metadata in backend storage.
my $result = $backend->update_session(
$session_id,
{
data => \%new_data,
expires_at => $new_expiration,
},
);
Must return:
{
success => 1,
}
Or on error:
{
success => 0,
message => "Error description",
}
delete_session
Deletes a session from backend storage.
my $result = $backend->delete_session($session_id);
Must return:
{
success => 1,
message => "Session deleted",
}
cleanup_sessions
Removes all expired sessions from backend storage.
my $result = $backend->cleanup_sessions();
Must return:
{
success => 1,
deleted_count => 15,
}
delete_user_session
Deletes all sessions for a specific user from backend storage.
my $result = $backend->delete_user_session($user_id);
Must return:
{
success => 1,
deleted_count => 3,
}
UTILITY METHODS
generate_session_id
Generates a cryptographically secure random session ID.
my $id = $backend->generate_session_id();
Returns: 40-character lowercase hex string (160 bits of entropy) generated from the operating system's CSPRNG via Crypt::URandom.
SEE ALSO
Concierge::Sessions::SQLite - SQLite backend implementation
Concierge::Sessions::File - File backend implementation
Concierge::Sessions - Session manager
AUTHOR
Bruce Van Allen <bva@cruzio.com>
LICENSE
Artistic License 2.0