NAME
Konstrukt::Session - Session management (Cookies/Session)
SYNOPSIS
The user will automatically get a session and you (as a plugin developer) can access the session object easily like this:
$Konstrukt::Session->method();
The following methods are available:
$Konstrukt::Session->activated(); #returns true if the session management is activated
$sid = $Konstrukt::Session->session_id($key); #get session id
$Konstrukt::Session->set($key => $value); #set value
$boolean = $Konstrukt::Session->exists($key); #does this key exist?
$value = $Konstrukt::Session->get($key); #get value
@keys = $Konstrukt::Session->keys(); #get all keys
$Konstrukt::Session->delete($key); #delete specified key
$Konstrukt::Session->clear(); #clear all keys
That's currently exactly what the CPAN-module Session offers, since Session currently is the only method of handling sessions internally. As Session uses Apache::Session and Apache::Session::Flex internally, you might also want to take a look at those.
Currently only the MySQL backend has been tested so the settings may not be apropriate to cover all backends offered by Apache::Session.
DESCRIPTION
This module provides easy session management for your plugins/websites.
CONFIGURATION
To use the session management it must be activated in your konstrukt.settings (it's deactivated by default).
#Session management
session/use 1 #default: 0
#backend module. probably all Apache::Session backends possible, but not tested
session/store MySQL
#dbi source. will default to your Konstrukt::DBI settings, when not specified
session/source dbi:mysql:database:host
session/user user
session/pass pass
session/timeout 60 #default: delete sessions that haven't been used for 60 minutes
#session/table session #currently unsupported
#only for backend store "File". Note: The path does _not_ relate to your document root!
session/directory /tmp/sessions #default: save sessions in dir /tmp/sessions. you have to create that dir!
#only for backend store "DB_file". Note: The path does _not_ relate to your document root!
session/file /tmp/sessions #default: save sessions in file /tmp/sessions
#show error message, if session could not be loaded or silently create a new one
session/show_error 1
METHODS
new
Constructor of this class
init
Initialization of this class
Parameters: none
install
Initializes the backend according the settings (e.g. create tables).
Parameters:
none
activated
Returns true if the session management is activated and ready to use.
create_session
Creates a new session and sets an SID-cookie
Parameters:
none
set_session
Sets a timestamp for the session and sets it as an attribute of this object
Parameters:
$session - The session object
session_cleanup
Deletes old sessions from the database
Parameters:
none
session wrapper methods
Wrapper methods for the usual methods of the session backend. For more indormation take a look at e.g. Session.
(Implemented using AUTOLOAD.)
Methods
set('key', 'value') - Set a value
get('key') - Retrieve a value
remove('key') - Delete a key
clear() - Delete all keys
session_id() - Returns the current session id
exists('key') - Returns true if the key exists
keys() - Returns an array with the keys within the session
delete() - Delete the session
release() - Release the session
AUTHOR
Copyright 2006 Thomas Wittek (mail at gedankenkonstrukt dot de). All rights reserved.
This document is free software. It is distributed under the same terms as Perl itself.