NAME
PAGI::Middleware::Session::State - Base class for session state extraction
SYNOPSIS
package My::State;
use parent 'PAGI::Middleware::Session::State';
sub extract {
my ($self, $scope) = @_;
# Return session ID or undef
}
sub inject {
my ($self, $headers, $id, $options) = @_;
# Push response header onto @$headers
}
DESCRIPTION
PAGI::Middleware::Session::State defines the interface for session ID transport. Subclasses determine how the session ID is extracted from incoming requests and injected into outgoing responses.
METHODS
new
my $state = PAGI::Middleware::Session::State->new(%options);
Create a new state handler.
extract
my $session_id = $state->extract($scope);
Extract the session ID from the PAGI scope. Returns the session ID string or undef if none is found. Subclasses must implement this.
inject
$state->inject(\@headers, $id, \%options);
Inject the session ID into the response by pushing header arrayrefs onto the provided headers array. Subclasses must implement this.
clear
$state->clear(\@headers);
Clear the client-side session state (e.g., expire a cookie). Called when a session is destroyed. The default implementation is a no-op, suitable for state handlers where the client manages transport (Header, Bearer). Cookie-based state handlers should override this to emit an expired Set-Cookie header.
SEE ALSO
PAGI::Middleware::Session::State::Cookie - Cookie-based session IDs
PAGI::Middleware::Session - Session management middleware