GX::Session

Module Version: 0.2000_01

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:
Returns:
Exceptions:

Public Methods

clear

Deletes the session data.

$session->clear;

context

Returns the associated context object.

$context = $session->context;
Returns:

data

Returns / sets the session data.

$data = $session->data;
$data = $session->data( $data );
Arguments:
  • $data ( HASH reference ) [ optional ]
Returns:
  • $data ( HASH reference )
Exceptions:

Alternative syntax:

$data = $session->data( %data );
Arguments:
  • %data ( named list )
Returns:
  • $data ( HASH reference )
Exceptions:

delete_data

Deletes the specified session data key / value pair.

$session->delete_data( $key );
Arguments:
  • $key ( string )

end

Ends the session.

$session->end;
Exceptions:

expires_at

Returns the expiration (Unix) time of the session.

$time = $session->expires_at;
Returns:
  • $time ( integer | undef )

get_data

Returns the session data for the given key.

$value = $session->get_data( $key );
Arguments:
  • $key ( string )
Returns:
  • $value ( scalar )

id

Returns the session identifier.

$id = $session->id;
Returns:
  • $id ( string | undef )

id_generator

Returns the session ID generator.

$id_generator = $session->id_generator;
Returns:

is_active

Returns true if the session is active, otherwise false.

$result = $session->is_active;
Returns:
  • $result ( bool )

is_expired

Returns true if the session is expired, otherwise false.

$result = $session->is_expired;
Returns:
  • $result ( bool )

is_invalid

Returns true if the session is invalid, otherwise false.

$result = $session->is_invalid;
Returns:
  • $result ( bool )

is_new

Returns true if the session is new, otherwise false.

$result = $session->is_new;
Returns:
  • $result ( bool )

is_resumed

Returns true if the session is resumed, otherwise false.

$result = $session->is_resumed;
Returns:
  • $result ( bool )

is_stored

Returns true if the session is stored, otherwise false.

$result = $session->is_stored;
Returns:
  • $result ( bool )

is_unknown

Returns true if the session is unknown, otherwise false.

$result = $session->is_unknown;
Returns:
  • $result ( bool )

lifetime

Returns the maximum lifetime of the session in seconds.

$seconds = $session->lifetime;
Returns:
  • $seconds ( integer )

options

Returns the session options as a list of key / value pairs.

%options = $session->options;
Returns:
  • %options ( named list )

remote_address

Returns the remote address the session is bound to.

$remote_address = $session->remote_address;
Returns:
  • $remote_address ( string | undef )

reset

Resets the session.

$session->reset;

resume

Resumes the (specified) session.

$result = $session->resume;
$result = $session->resume( $session_id );
Arguments:
  • $session_id ( string ) [ optional ]
Returns:
  • $result ( bool )
Exceptions:

save

Saves the session.

$session->save;
Exceptions:

set_data

Sets the specified session data key / value pair.

$session->set_data( $key => $value );
Arguments:
  • $key ( string )
  • $value ( scalar )

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;
Exceptions:

started_at

Returns the (Unix) time the session was started.

$time = $session->started_at;
Returns:
  • $time ( integer | undef )

store

Returns the session store.

$store = $session->store;
Returns:

timeout

Returns the session timeout interval in seconds.

$seconds = $session->timeout;
Returns:
  • $seconds ( integer )

tracker

Returns the session tracker.

$tracker = $session->tracker;
Returns:

updated_at

Returns the (Unix) time the session was updated last.

$time = $session->updated_at;
Returns:
  • $time ( integer | undef )

variables

Returns all session data keys.

@keys = $session->variables;
Returns:
  • @keys ( strings )

AUTHOR

Jörg A. Uzarek <uzarek@runlevelnull.de>

COPYRIGHT AND LICENSE

Copyright © 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.