OpenFrame::WebApp::Session - sessions for OpenFrame-WebApp
use OpenFrame::WebApp::Session; my $session = new OpenFrame::WebApp::Session() ->set($key1, $val1)->set($key2, $val2); $val = $session->get( $key ); my $id = $session->store(); my $restored = OpenFrame::WebApp::Session->fetch( $id );
The OpenFrame::WebApp::Session class is an abstract wrapper around session storing classes like Cache::FileCache, CGI::Session, Apache::Session, etc.
OpenFrame::WebApp::Session
Cache::FileCache
CGI::Session
Apache::Session
In WebApp, sessions are a storable hash with a session id, and an expiry period.
Just incase something like Pixie is used to store the sessions, you should always use the set/get methods to retrieve keys from the hash.
This class was meant to be used with OpenFrame::WebApp::Session::Factory.
OpenFrame::WebApp::Session::Factory
set/get the hash of $session_types => $class_names known to this class.
set/get the session id (stored as 'session_id', FYI).
set/get the expiry period (stored as 'expiry_period', FYI). This should be a string compatible with Time::ParseDate.
Time::ParseDate
parses the expiry period with Time::ParseDate, and returns the result in seconds.
Note: $time == undef implies no expiry time, whereas $time <= 0 implies expires immediately.
$time == undef
$time <= 0
associates $key with $val, and returns this object.
returns value associated with $key.
abstract method, saves the session to disk and returns the session id.
abstract method, returns the session with the given $id or undef if not found or expired.
abstract method, removes this object from the store, and returns this object. if called as a class method, $id is expected.
internal method to generate a new session id.
Read through the source of this package and the known sub-classes first. The minumum you need to do is this:
use base qw( OpenFrame::WebApp::Session ); OpenFrame::WebApp::Session->types->{my_type} = __PACKAGE__; sub store { ... return $id; } sub fetch { ... return new Some::Session(); } sub remove { ... return $self; }
You must register your session type if you want to use the Session::Factory.
Steve Purkis <spurkis@epn.nu>
Based on OpenFrame::AppKit::Session by James A. Duncan
OpenFrame::AppKit::Session
Copyright (c) 2003 Steve Purkis. All rights reserved. Released under the same license as Perl itself.
Time::ParseDate, OpenFrame::WebApp::Sesssion::Factory, OpenFrame::WebApp::Sesssion::FileCache, OpenFrame::WebApp::Segment::Sesssion::Loader
Similar modules:
OpenFrame::AppKit::Session, CGI::Session, Apache::Session
To install OpenFrame::WebApp, copy and paste the appropriate command in to your terminal.
cpanm
cpanm OpenFrame::WebApp
CPAN shell
perl -MCPAN -e shell install OpenFrame::WebApp
For more information on module installation, please visit the detailed CPAN module installation guide.