From: <Nei...@rc...> - 2007-10-25 14:30:30
|
I am trying to put in a simple session tracker. I thought I had followed the instructions for overloading the session routines, but I'm getting nothing . . . Please suggest things to try, or point out what I haven't noticed! Here's how my files now begin: <?php session_start(); include_once('exe/includes/session_auth.php'); . . . and here's "session_auth.php": <?php // require_once('../../Connections/mysqlconnect.php'); // required in calling routines function sess_touch($sess_path, $sess_name) { $GLOBAL['sessid'] = session_id(); $now = time(); $sqlUPDATE = "UPDATE sesssions SET touch = " . $now . " WHERE sessid = '" . $GLOBAL['sessid'] . "'"; $sqlINSERT = "INSERT sessions (sessid, login, touch) VALUES ('" . $GLOBAL['sessid'] . "', " . $now . ", " . $now . ")"; if( (!mysql_query($sqlUPDATE)) & (!mysql_query($sqlINSERT)) ) { // fail } return 1; } function sess_close() { $now = time(); mysql_query("UPDATE sessions SET logout = $now WHERE sessid = '" . $GLOBAL['sessid'] . "'"); return 1; } function sess_write($sess_id, $data) { $now = time(); mysql_query("UPDATE sessions SET touch = $now WHERE sessid = '" . $GLOBAL['sessid'] . "'"); return 1; } function sess_destroy($sess_id) { $now = time(); mysql_query("UPDATE sessions SET logout = $now WHERE sessid = '" . $GLOBAL['sessid'] . "'"); return 1; } function sess_gc($sess_maxlifetime) { $now = time(); mysql_query("UPDATE sessions SET garbagecollection = $now WHERE touch + $sess_maxlifetime < $now"); return 1; } session_set_save_handler("sess_touch", // same for _open and _read "sess_close", "sess_touch", "sess_write", "sess_destroy", "sess_gc"); ?> Neil Rest -- Nei...@rc... http://users.rcn.com/neilrest/resume/ http://users.rcn.com/neilrest/resume/NeilRest.doc (Word format) |