$ADODB_SESSION_EXPIRE_NOTIFY
Description
ADOdb uses a global variable $ADODB_SESSION_EXPIRE_NOTIFY that must be predefined before session start to store the notification configuration. It is an array with 2 elements, the first being the name of the session variable you would like to store in the EXPIREREF field, and the 2nd is the notification function's name.
For example, suppose we want to be notified when a user's session has expired, based on the userid. When the user logs in, we store the id in the global session variable $USERID. The function name is NotifyFn.
So we define (before session_start() is called):
$ADODB_SESSION_EXPIRE_NOTIFY = array('USERID','NotifyFn');
When the NotifyFn is called (when the session expires), the $EXPIREREF holding the user id is passed in as the first parameter, e.g. NotifyFn($userid, $sesskey). The session key (which is the primary key of the record in the sessions table) is the 2nd parameter.
Usage
This example of a Notification function deletes records in the database and temporary files:
function NotifyFn($expireref, $sesskey) { /* * Globalizes session connection object */ global $ADODB_SESS_CONN; $user = $ADODB_SESS_CONN->qstr($expireref); $ADODB_SESS_CONN->Execute("delete from shopping_cart where user=$user"); system("rm /work/tmpfiles/$expireref/*"); } $GLOBALS['USERID'] = GetUserID(); $ADODB_SESSION_EXPIRE_NOTIFY = array('USERID','NotifyFn'); session_start();