The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

Egg::Model::Session::Manager::TieHash - Tie HASH base class for session manager.

SYNOPSIS

  package MyApp::Model::Session::TieHash;
  use base qw/ Egg::Model::Session::Manager::TieHash /;

DESCRIPTION

It is a base class for the TieHash class of the component module generated with Egg::Helper::Model::Sesson to use it.

METHODS

This module has succeeded to Egg::Component.

TIEHASH

This constructor is called among constructors of the Manager class. Therefore, because the application is executed at the same time when model is called, it is not necessary to consider it.

  # It is called at the same time at this time.
  my $session= $e->model('session_label');
  
  # The object of this class is obtained by 'Context' method of the Manager class.
  my $tiehash= $session->context;

data

The raw data of the session is returned.

Because 'is_update' is not renewed even if this value is operated directly, data is not preserved with 'close' method.

The thing used directly doesn't come recommended usually. Or, after the value is substituted, 'is_update' should be made effective.

  # This is equivalent to $session->{hoge}.
  my $hoge= $tiehash->data->{hoge};
  
  # 'is_update' is made effective if it saves data by the 'close' method.
  $tiehash->data->{banban}= 'hooo';
  $tiehash->is_update(1);
  
  # Only this makes 'is_update' effective usually.
  $session->{banban}= 'hooo';

attr

The HASH reference of the data etc. shared in this class is returned.

e

The object of the project is returned.

session_id

ID of the session that has been treated now is returned.

startup

It is a method of the terminal to keep interchangeability with the module of an old version.

is_new

Ture is returned if a present session is new.

is_update

When the value is substituted for the session data, it becomes effective.

However, please note not becoming effective because the substitution of the data of manipulating data directly by the data method and a deep hierarchy cannot be detected.

  # As for this, 'is_update' becomes effective at the same time. There is no 
  # necessity especially considered usually.
  $session->{hoge}= 'boo';
  
  # In this case, 'is_update' : like invalidity.
  $session->{mydata}{banban}= 'booo';
  
  # However, if the value of single hierarchical key can be updated even once,
  # 'is_update' becomes effective.
  $session->{hoge}= 'boo';
  $session->{mydata}{banban}= 'booo';
  
  # When data is operated directly, it is necessary to update 'is_update' for 
  # oneself.
  $tiehash->data->{hoo}= 'boo';
  $tiehash->is_update(1);

init_session

The session is initialized.

If session ID is obtained from the client, reading existing data is tried. New session ID is issued and a new session is begun when failing in this reading.

change

Session ID is newly issued and it exchanges it for existing ID.

Data is succeeded as it is.

  $session->{hoge}= 'boo';
  my $session_id= $session->session_id;
  
  $session->change;
  
  # Then, $session_id and $session->session_id become not equal.
  # The content of $session->{hoge} : like 'boo'.

clear

All the session data is cleared, new session ID is issued, and it makes it to a new session.

  $session->{hoge}= 'boo';
  my $session_id= $session->session_id;
  
  $session->clear;
  
  # Then, $session_id and $session->session_id disappear equally,
  # and $session->{hoge} is not obtained.

accept_session_id

Session ID is received from the client or a new session is issued and it returns it.

This method is used to use it internally.

output_session_id

It is processed to send the client session ID.

This method is called from 'close' method.

create_session_id

New session ID is issued and 'is_new' method is made effective.

store_encode

This method originally wards off the received data as it is though it is a method for the encode of the data passed to 'insert' and 'update' method.

This method is override by Store system module such as Egg::Model::Session::Store::Base64.

store_decode

This method originally wards off the received data as it is though it is a method for deciphered doing the data received from 'restore' method.

This method is override by Store system module such as Egg::Model::Session::Store::Base64.

valid_session_id

This method originally wards off received ID as it is though it is a method for the judgment whether the format of session ID received from the client is correct.

This method is override by ID system module such as Egg::Model::Session::ID::SHA1.

close

The session is close.

If 'is_update' method is effective, it saves data.

If 'is_new' is effective at this time, 'insert' method and if it is invalid, 'update' method is used for preservation.

And, after it preserves it, 'is_new' and 'is_update' are invalidated.

This method need not usually be called by the application because it is called with '_finish' hook at the end of processing.

ABSOLUTE METHODS

  • restore, insert, update, get_bind_data, set_bind_data, issue_session_id, make_session_id,

When the component module with the above-mentioned method is not loaded, the exception is generated.

  __PACKAGE__->startup qw/
    Base::FileCache
    ID::SHA1
    Bind::Cookie
    /;

COMPONENT MODULES

It is a component module of package enclosing list. Egg::Plugin::SessionKit

Base system

It processes it concerning the preservation of the session data.

Egg::Model::Session::Base::DBI, Egg::Model::Session::Base::DBIC, Egg::Model::Session::Base::FileCache,

ID system

It processes it concerning session ID issue etc.

Egg::Model::Session::ID::IPaddr, Egg::Model::Session::ID::SHA1, Egg::Model::Session::ID::MD5, Egg::Model::Session::ID::UniqueID, Egg::Model::Session::ID::UUID,

Store system

The encode of the session data and processing concerning the decipherment are done.

Egg::Model::Session::Store::Base64, Egg::Model::Session::Store::UUencode,

Plugin system

The function is enhanced.

Egg::Model::Session::Plugin::AbsoluteIP, Egg::Model::Session::Plugin::AgreeAgent, Egg::Model::Session::Plugin::CclassIP, Egg::Model::Session::Plugin::Ticket,

SEE ALSO

Egg::Release, Egg::Model::Session, Egg::Model::Session::Manager::Base, Egg::Helper::Model::Session, Egg::Component, Tie::ExtraHash,

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.