GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages


Manual Reference Pages  -  WWWDB::SESSION (3)

.ds Aq ’

NAME

WWWdb::Session - Session-Handling for WWWdb

CONTENTS

SYNOPSIS



 use WWWdb::Session;

 $oSession   = Session->new($pDbHandle,
                            ["Id"        => $cSessionKey,]
                            ["IdLength"  => $iKeyLength]);

 $cStateInfo = $oSession->getState($cStateName);
 $cStateInfo = $oSession->setState($cStateName,
                                   $cStateValue);

 $oSession->DESTROY();

 $cId        = $oSession->getId();
 $bIdInDb    = $oSession->getIdAlreadyInDb();
 $iLength    = $oSession->getIdLength();



DESCRIPTION

The Session class

Every WWWdb-Session is identyfied by a Session-Id. This is a random generated hex-string with 16 characters by default. Using this session-id, the user can continue sessions, he already has started.

For every session WWWdb can store state-information, where the some information for the user can be placed. Every time this session gets re-acitvated, the session-parameters for this session get used.

Internally the state-information is stored in the database in the table <B>wwwdb_stateB>. When a Session-object gets allocated, the corresponding data will be fetched from the database. When the application runs, a cache of this parameters will be used. The DESTROY-method will write the cache back to the database.

    Note

If you want to flush all Objects to the Database during the session you only have to re-create the session-object. All changed objects will be stored in the database and a new object with the actual values gets allocated.

Pleas note, that you will get trouble, when you set up two instances of the same session-object, because the state-info is cached in the object!

    Class Methods

<B>newB>


 $oSession   = Session->new($pDbHandle,
                            ["Id"       => $cSessionKey,]
                            ["IdLength" => $iKeyLength]);



When you want to create a new session-class, you have to call this constructor. Because you want to acces the database we need the DBI-database-handle pDbHandle. The cSessionKey is the session-key, for which the session should be created. If you want a new session-key, you van give either "" or undef as parameter. The third thing we need, is the length of the key. The default is 16. The minimum value is 4, the maximum is 32.

When everything is ok, the session-data gets fetched, when the session does already exist, or a new record whith the key last_acces will be inserted. Then the session-object will be returned.

<B>getStateB>


 $cStateInfo = $oSession->Session::getState($cStateName);



This method reads the value of the record with the id cStateName from the internal hash and gives it back as the result. If the record does not exist in the database, undef is returned.

<B>setStateB>


 $cStateInfo = $oSession->Session::setState($cStateName,
                                            $cStateValue);



setState sets the value of the state-record with the name cStateName to cStateValue. If the value is undef the corresponding record will be deleted from the database.

<B>DESTROYB> This method will be called automatically b Perl, when the object is going to be destroyed. Then the internal cache must be flushed to the database. According to the existence of a record in the database the following actions must be triggered:



  +----------+---------------------------+----------------------+
  | Already  |   What happened with the  |  What happens in the |
  | in db    |   Value of the Record     |  Database            |
  +----------+---------------------------+----------------------+
  | No       |   Set to some Value       |  INSERT record       |
  +----------+---------------------------+----------------------+
  | Yes      |   Set to some Value       |  UPDATE record       |
  +----------+---------------------------+----------------------+
  | No       |   Set to undef            |  - Ignore -          |
  +----------+---------------------------+----------------------+
  | Yes      |   Set to undef            |  DELETE record       |
  +----------+---------------------------+----------------------+



    Class Attributes

<B>IdB>


 $cId        = $oSession->getId();



Get the Id of this session. (Read-only)

<B>IdAlreadyInDbB>


 $bIdInDb    = $oSession->getIdAlreadyInDb();



True, when this session was already existing in the database. (Read-only)

<B>IdLengthB>


 $iLength    = $oSession->getIdLength();



The length of the session-id. (Read-only)

Search for    or go to Top of page |  Section 3 |  Main Index


perl v5.20.3 WWWDB::SESSION (3) 2002-03-14

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with manServer 1.07.