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
WWWdb::Session(3) User Contributed Perl Documentation WWWdb::Session(3)

WWWdb::Session - Session-Handling for WWWdb

 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();

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 wwwdb_state. 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.

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!

new
 $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.

getState
 $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.

setState
 $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.

DESTROY
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       |
  +----------+---------------------------+----------------------+
    

Id
 $cId        = $oSession->getId();
    

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

IdAlreadyInDb
 $bIdInDb    = $oSession->getIdAlreadyInDb();
    

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

IdLength
 $iLength    = $oSession->getIdLength();
    

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

2002-03-14 perl v5.32.1

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

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