Database Abstraction Layer for PHP

User Tools

Site Tools




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):


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.


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/*");
v5/session/reference/adodb_session_expire_notify.txt · Last modified: 2016/05/22 16:50 by mnewnham