Krang::Session - session handling for Krang


  use Krang::ClassLoader Session => qw(%session);
  # get some session data
  my $bang = $session{buck};
  # get the session id
  my $session_id = $session{_session_id};
  # set from session data
  $session{buck} = $bang + 1;
  # delete from the session hash
  delete $session{buck};
  # it's that simple


This module provides access to a peristent hash per user session. This is available both in Apache/mod_perl, where a user session lasts from login to logout, and from shell scripts, where a user session lasts from process start to process end.

The session hash should be used for data that must persist between requests but is not permanent enough to be stored in the database. The most obvious usage is to maintain state while editing an object before eventually saving changes to the database.

NOTE The session hash should not be used as a general mechanism to speed up Krang. This is not a cache, it is an intermediary data store.

Sessions older than 24 hours are cleaned out daily by the scheduler. See Krang::Schedule::Action::clean for details.


Aside from the exported %session hash, the module supports the following routines.