NAME
GX::Session - Session component
SYNOPSIS
package MyApp::Session::Default;
use GX::Session;
__PACKAGE__->setup(
store => [
'GX::Session::Store::Database' => {
database => 'MyApp::Database::Default',
table => 'sessions'
}
],
tracker => [
'GX::Session::Tracker::Cookie' => {
cookie_attributes => {
name => 'SESSION_ID',
domain => 'mysite.com',
path => '/',
secure => 1
}
}
],
id_generator => 'GX::Session::ID::Generator::MD5',
lifetime => 86400,
timeout => 3600
);
1;
DESCRIPTION
This module provides the GX::Session class which inherits directly from GX::Component and GX::Class::Object.
METHODS
Constructor
new
Returns a new session object.
$session = $session_class->new( %attributes );
- Attributes:
-
context
( GX::Context object ) [ required ]
- Returns:
-
$session
( GX::Session object )
- Exceptions:
Public Methods
clear
Deletes the session data.
$session->clear;
context
Returns the associated context object.
$context = $session->context;
- Returns:
-
$context
( GX::Context object )
data
Returns / sets the session data.
$data = $session->data;
$data = $session->data( $data );
Alternative syntax:
$data = $session->data( %data );
delete_data
Deletes the specified session data key / value pair.
$session->delete_data( $key );
end
Ends the session.
$session->end;
expires_at
Returns the expiration (Unix) time of the session.
$time = $session->expires_at;
get_data
Returns the session data for the given key.
$value = $session->get_data( $key );
id
Returns the session identifier.
$id = $session->id;
id_generator
Returns the session ID generator.
$id_generator = $session->id_generator;
- Returns:
-
$id_generator
( GX::Session::ID::Generator object )
is_active
Returns true if the session is active, otherwise false.
$result = $session->is_active;
is_expired
Returns true if the session is expired, otherwise false.
$result = $session->is_expired;
is_invalid
Returns true if the session is invalid, otherwise false.
$result = $session->is_invalid;
is_new
Returns true if the session is new, otherwise false.
$result = $session->is_new;
is_resumed
Returns true if the session is resumed, otherwise false.
$result = $session->is_resumed;
is_stored
Returns true if the session is stored, otherwise false.
$result = $session->is_stored;
is_unknown
Returns true if the session is unknown, otherwise false.
$result = $session->is_unknown;
lifetime
Returns the maximum lifetime of the session in seconds.
$seconds = $session->lifetime;
options
Returns the session options as a list of key / value pairs.
%options = $session->options;
remote_address
Returns the remote address the session is bound to.
$remote_address = $session->remote_address;
reset
Resets the session.
$session->reset;
resume
Resumes the (specified) session.
$result = $session->resume;
$result = $session->resume( $session_id );
save
Saves the session.
$session->save;
set_data
Sets the specified session data key / value pair.
$session->set_data( $key => $value );
setup
Sets up the session component.
$session_class->setup( %options );
- Options:
-
auto_resume
( bool )A boolean flag indicating whether or not to automatically try to resume the session. Defaults to true.
auto_save
( bool )A boolean flag indicating whether or not to automatically save the session. Defaults to true.
auto_start
( bool )A boolean flag indicating whether or not to automatically start the session. Defaults to false.
bind_to_remote_address
( bool )A boolean flag indicating whether or not to bind the session to the client's IP address. Defaults to true.
id_generator
( GX::Session::ID::Generator object or class |ARRAY
reference )The session ID generator to use. Defaults to a GX::Session::ID::Generator::MD5 instance.
lifetime
( integer )The maximum lifetime of the session in seconds. Defaults to 86400 seconds (1 day).
store
( GX::Session::Store object or class |ARRAY
reference ) [ required ]The session store to use.
timeout
( integer )The session timeout in seconds. Defaults to 3600 seconds (1 hour).
tracker
( GX::Session::Tracker object or class |ARRAY
reference )The session tracker to use. Defaults to a GX::Session::Tracker::Cookie instance.
- Exceptions:
start
Starts the session.
$session->start;
started_at
Returns the (Unix) time the session was started.
$time = $session->started_at;
store
Returns the session store.
$store = $session->store;
- Returns:
-
$store
( GX::Session::Store object )
timeout
Returns the session timeout interval in seconds.
$seconds = $session->timeout;
tracker
Returns the session tracker.
$tracker = $session->tracker;
- Returns:
-
$tracker
( GX::Session::Tracker object )
updated_at
Returns the (Unix) time the session was updated last.
$time = $session->updated_at;
variables
Returns all session data keys.
@keys = $session->variables;
SEE ALSO
Subcomponents:
AUTHOR
Jörg A. Uzarek <uzarek@runlevelnull.de>
COPYRIGHT AND LICENSE
Copyright (c) 2009-2011 Jörg A. Uzarek.
This module is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License Version 3 as published by the Free Software Foundation.