OpenInteract::Session - Implement session handling in the framework


 # In Note that $R->session translates to
 # OpenInteract::Session::Blah thanks to the server configuration key
 # 'system_alias::session'


 # Access the data the session from any handler

 $R->{session}{my_stateful_data} = "oogle boogle";
 $R->{session}{favorite_colors}{red} += 5;

 # And from any template you can use the OI template plugin (see
 # OpenInteract::Template::Plugin)

 <p>The weight of your favorite colors are:
 [% FOREACH color = keys OI.session.favorite_colors %]
   * [% color %] -- [% OI.session.favorite_colors.color %]
 [% END %]

 # in the main content handler,
 # Only call once you're done accessing the data



Sessions are a fundamental part of OpenInteract, and therefore session handling is fairly transparent. We rely on Apache::Session to do the heavy-lifting for us.

This handler has two public methods: parse() and save(). Guess in which order they are meant to be called?

This class also requires you to implement a subclass that overrides the _create_session method with one that returns a valid Apache::Session tied hashref. OpenInteract provides OpenInteract::Session::DBI for DBI databases, OpenInteract::Session::SQLite for SQLite databases, and , OpenInteract::Session::File using the filesystem. Implementations using other media are left as an exercise for the reader.

Subclasses should refer to the package variable $OpenInteract::Session::COOKIE_NAME for the name of the cookie to create, and should throw a '310' error of type 'session' if unable to connect to the session data source to create a session.

You can create sessions that will expire if not used by setting the session_info.expires_in server configuration key. See the description below in CONFIGURATION for more information.



Get the session_id and fetch a session for this user; if one does not exist, just set the {session} property of $R to an anonymous hashref. If data exist when we want to save it, we will create a session form it then. Otherwise we will not bother.


Save the session off for later. If we did not initially create one do so now if there is information in {session}.


The following configuration keys are used:

  • session_info.expiration (optional)

    Used to set the time a session lasts. See CGI for an explanation of the relative date strings accepted.

  • session_info.expires_in (optional)

    Used to set the time (in number of minutes) greater than which a session will expire due to inactivity.




None known.



OpenInteract::Template::Plugin: makes the session hash information available to the template

OpenInteract::Cookies::* -- routines for parsing, creating, setting cookie information so we can match up users with session information


Copyright (c) 2001-2002, inc.. All rights reserved.

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


Chris Winters <>