Quick Navigator

Search Site

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

Contact Us
Online Help
Domain Status
Man Pages

Virtual Servers

Topology Map

Server Agreement
Year 2038

USA Flag



Man Pages

Manual Reference Pages  -  WWWDB::SESSION (3)

.ds Aq ’


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,


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


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.


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


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


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


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

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


 $cId        = $oSession->getId();

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


 $bIdInDb    = $oSession->getIdAlreadyInDb();

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


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