Masatoshi Mizuno
and 1 contributors

NAME

Egg::Model::Session::Base::DBI - Session management by DBI.

SYNOPSIS

  package MyApp::Model::Sesion;
  
  __PACKAGE__->config(
   dbi => {
     label         => 'dbi_label_name',
     dbname        => 'sessions',
     id_field      => 'id',
     data_field    => 'a_session',
     time_field    => 'lastmod',
     prepare_cache => 1,
     },
   );
  
  __PACKAGE__->startup(
   Base::DBI
   Store::Base64
   ID::SHA1
   Bind::Cookie
   );

DESCRIPTION

The session data is preserved by using DBI.

'Egg::Model::DBI' should be able to be used for use.

And, Egg::Helper::Model::Session. 'Base::DBI' is added to startup of the component module that generates.

'Base::FileCache' in this systemIt is not possible to cooperate and delete it, please.

Moreover, it is necessary to load Store system module to treat the session data appropriately.

  __PACKAGE__->startup(
   Base::DBI
   Store::Base64
   ID::SHA1
   Bind::Cookie
   );

If Egg::Plugin::EasyDBI is effective, it is late commit.

CONFIGURATION

It sets in config of the session component module and it sets it to 'dbi' key with HASH.

label

Label name to use Egg::Model::DBI.

Default is 'dbi::main'.

dbname

Table name that preserves session data.

Default is 'sessions'.

Please make this table beforehand by the following compositions.

  CREATE TABLE [dbname] (
    id          char(32)  primary key,
    lastmod     timestamp,
    a_session   text
    );

id_field

Name of session ID column.

Default is 'id'.

data_field

Name of session data column.

Default is 'a_session'.

time_field

Name of updated day and hour column.

Default is 'lastmod'.

prepare_cache

When this item is made effective, 'prepare_cached' method of DBI comes to be used by the restore method.

Default is undefined.

METHODS

Because most of these methods is the one that Egg::Model::Session internally uses it, it is not necessary to usually consider it on the application side.

_label

The label name of the model used is returned.

_insert

SQL statement used by the insert method is returned.

_update

SQL statement used by the update method is returned.

_delete

SQL statement used by the delete method is returned.

_clear

SQL statement used by the clear method is returned.

restore ([SESSION_ID])

The session data obtained by received SESSION_ID is returned.

When SESSION_ID is not obtained, it acquires it in 'session_id' method.

insert ([SESSION_DATA], [SESSION_ID])

New session data is preserved.

SESSION_DATA is indispensable.

When SESSION_ID is not obtained, it acquires it in 'Session_id' method.

update ([SESSION_DATA], [SESSION_ID])

Existing session data is updated.

SESSION_DATA is indispensable.

When SESSION_ID is not obtained, it acquires it in 'session_id' method.

delete ([SESSION_ID])

The session data is deleted.

SESSION_ID is indispensable.

  $session->delete('abcdefghijkemn12345');

clear_sessions ([TIME_VALUE])

All the session data before TIME_VALUE is deleted.

  # The update on deletes all the session data that not is.
  $session->clear_sessions( time - (24 * 60 * 60) );

close

Egg::Model::Session::Manager::TieHash Commit is done back.

However, if 'is_update' method is invalid, rollback is issued. In a word, if data was not substituted for the session, the data is annulled.

When Egg::Plugin::EasyDBI is loaded, nothing is done.

SEE ALSO

Egg::Release, Egg::Model::Session, Egg::Model::Session::Manager::Base, Egg::Model::Session::Manager::TieHash, Egg::Model, Egg::Model::DBI, Time::Piece::MySQL,

AUTHOR

Masatoshi Mizuno <lushe@cpan.org>

COPYRIGHT AND LICENSE

Copyright (C) 2008 Bee Flag, Corp. <http://egg.bomcity.com/>, All Rights Reserved.

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.6 or, at your option, any later version of Perl 5 you may have available.