NAME

Gantry::Plugins::Session - Plugin for cookie based session management

SYNOPSIS

In Apache Perl startup or app.cgi or app.server:

<Perl>
    # ...
    use MyApp qw{ -Engine=CGI -TemplateEngine=TT Session };
</Perl>

Inside MyApp.pm:

use Gantry::Plugins::Session;

DESCRIPTION

This plugin mixes in a method that will provide simple session management. Session management is done by setting a cookie to a known value. The session cookie will only last for the duration of the browser's usage. The session cookie can be considered an ID and for all practical purposes is an 'idiot' number.

Session state can be associated with the session id. The state is stored within the session cache. Once again this is short time storage. The cache is periodically purged of expired items.

Note that you must include Session in the list of imported items when you use your base app module (the one whose location is app_rootp). Failure to do so will cause errors.

CONFIGURATION

The following items can be set by configuration:

session_secret           a plain text key used to encrypt the cookie
session_title            a title for the session template
session_wrapper          the wrapper for the session template
session_template         the template for missing cookies notice

The following reasonable defaults are being used for those items:

session_secret           same as used by Gantry::Plugins::AuthCookie.pm
session_title            "Missing Cookies"
session_wrapper          default.tt
session_template         session.tt

METHODS

session_id

This method returns the current session id.

$session = $self->session_id();
session_store

This method will store a key/value pair within the session cache. Multiple key/value pairs may be stored per session.

$self->session_store('key', 'value');
session_retrieve

This method will retireve the stored value for a given key.

$data = $session_retrieve('key');
session_remove

This method will remove the stored value for a given key.

$session_remove('key');
get_callbacks

For use by Gantry.pm. Registers the callbacks needed for session management during the PerlHandler Apache phase or its moral equivalent.

PRIVATE SUBROUTINES

Encryption routine for cookie.

initialize

Callback to initialize plugin configuration.

do_cookiecheck

A URL to check to see if cookies are activated on the browser. If they are not, then a page will be displayed prompting them to turn 'cookies' on.

SEE ALSO

Gantry

AUTHOR

Kevin L. Esteb <kesteb@wsipc.org>

COPYRIGHT AND LICENSE

Copyright (C) 2007 Kevin L. Esteb

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.6 or, at your option, any later version of Perl 5 you may have available.