V3.50 19 May 2003 (c) 2000-2003 John Lim (jlim#natsoft.com.my)
This software is dual licensed using BSD-Style and LGPL. Where there is any discrepancy, the BSD-Style license will take precedence. This means you can use it in proprietary and commercial products.
There are 3 session management files that you can use:
adodb-session.inc.php : The default adodb-session-clob.inc.php : Use this if you are storing DATA in clobs adodb-cryptsession.inc.php : Use this if you want to store encrypted session data in the database Examples GLOBAL $HTTP_SESSION_VARS; include('adodb.inc.php'); include('adodb-session.php'); session_start(); session_register('AVAR'); $HTTP_SESSION_VARS['AVAR'] += 1; print "\$HTTP_SESSION_VARS['AVAR']={$HTTP_SESSION_VARS['AVAR']}
"; To force non-persistent connections, call adodb_session_open first before session_start(): GLOBAL $HTTP_SESSION_VARS; include('adodb.inc.php'); include('adodb-session.php'); adodb_sess_open(false,false,false); session_start(); session_register('AVAR'); $HTTP_SESSION_VARS['AVAR'] += 1; print "\$HTTP_SESSION_VARS['AVAR']={$HTTP_SESSION_VARS['AVAR']}
"; To use a encrypted sessions, simply replace the file: GLOBAL $HTTP_SESSION_VARS; include('adodb.inc.php'); include('adodb-cryptsession.php'); session_start(); And the same technique for adodb-session-clob.inc.php: GLOBAL $HTTP_SESSION_VARS; include('adodb.inc.php'); include('adodb-session-clob.php'); session_start(); Installation 1. Create this table in your database (syntax might vary depending on your db): create table sessions ( SESSKEY char(32) not null, EXPIRY int(11) unsigned not null, EXPIREREF varchar(64), DATA text not null, primary key (sesskey) ); For the adodb-session-clob.inc.php version, create this: create table sessions ( SESSKEY char(32) not null, EXPIRY int(11) unsigned not null, EXPIREREF varchar(64), DATA CLOB, primary key (sesskey) ); 2. Then define the following parameters in this file: $ADODB_SESSION_DRIVER='database driver, eg. mysql or ibase'; $ADODB_SESSION_CONNECT='server to connect to'; $ADODB_SESSION_USER ='user'; $ADODB_SESSION_PWD ='password'; $ADODB_SESSION_DB ='database'; $ADODB_SESSION_TBL = 'sessions' 3. Recommended is PHP 4.0.6 or later. There are documented session bugs in earlier versions of PHP. 4. If you want to receive notifications when a session expires, then you can tag a session with an EXPIREREF, and before the session record is deleted, we can call a function that will pass the EXPIREREF as the first parameter, and the session key as the second parameter. To do this, define a notification function, say NotifyFn: function NotifyFn($expireref, $sesskey) { } Then define a global variable, with the first parameter being the global variable you would like to store in the EXPIREREF field, and the second is the function name. In this example, we want to be notified when a user's session has expired, so we store the user id in $USERID, and make this the value stored in the EXPIREREF field: $ADODB_SESSION_EXPIRE_NOTIFY = array('USERID','NotifyFn');
Also see the core ADOdb documentation.