/Web-Starch

Implementation independent session management.

Primary LanguagePerl

NAME

Web::Starch - Implementation independent session management.

SYNOPSIS

my $starch = Web::Starch->new(
    expires => 60 * 15, # 15 minutes
    store => {
        class   => '::Memory',
    },
);
my $new_session = $starch->session();
my $existing_session = $starch->session( $id );

DESCRIPTION

This module provides a generic interface to managing sessions and is often refered to as the "manager" in this documentation.

Please see Web::Starch::Manual for some good holistic starter documentation.

This class support method proxies as described in "METHOD PROXIES" in Web::Starch::Manual.

PLUGINS

my $starch = Web::Starch->new_with_plugins(
    ['::CookieArgs'],
    store => { class=>'::Memory' },
    cookie_name => 'my_session',
);
my $session = $starch->session();
print $session->cookie_args->{name}; # my_session

Starch plugins are applied using the new_with_plugins constructor method. The first argument is an array ref of plugin names. The plugin names can be fully qualified, or relative to the Web::Starch::Plugin namespace. A leading :: signifies that the plugin's package name is relative.

More information about plugins can be found at "PLUGINS" in Web::Starch::Manual.

REQUIRED ARGUMENTS

store

The Web::Starch::Store storage backend to use for persisting the session data. A hashref must be passed and it is expected to contain at least a class key and will be converted into a store object automatically.

The class can be fully qualified, or relative to the Web::Starch::Store namespace. A leading :: signifies that the store's package name is relative.

More information about stores can be found at "STORES" in Web::Starch::Manual.

OPTIONAL ARGUMENTS

expires

How long, in seconds, a session should live after the last time it was modified. Defaults to 60 * 60 * 2 (2 hours).

See "EXPIRATION" in Web::Starch::Manual for more information.

expires_session_key

The session key to store the "expires" in Web::Starch::Session value in. Defaults to __SESSION_EXPIRES__.

modified_session_key

The session key to store the "modified" in Web::Starch::Session value in. Defaults to __SESSION_MODIFIED__.

created_session_key

The session key to store the "created" in Web::Starch::Session value in. Defaults to __SESSION_CREATED__.

factory

The underlying Web::Starch::Factory object which manages all the plugins and session/store object construction.

METHODS

session

my $new_session = $starch->session();
my $existing_session = $starch->session( $id );

Returns a new Web::Starch::Session (or whatever "session_class" in Web::Starch::Factory returns) object for the specified session ID.

If no ID is specified, or is undef, then an ID will be automatically generated.

Additional arguments can be passed after the ID argument. These extra arguments will be passed to the session object constructor.

AUTHOR

Aran Clary Deltac <bluefeet@gmail.com>

ACKNOWLEDGEMENTS

Thanks to ZipRecruiter for encouraging their employees to contribute back to the open source ecosystem. Without their dedication to quality software development this distribution would not exist.

LICENSE

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.