Hi,
I am trying to use session_set_save_handler to allow me to save sessions within a mySQL database using the code below.
Everytime I try to load the page I recieve an Application Error regarding the httpd.exe, as demonstrated by the image below.
http://i48.tinypic.com/2i9l2ip.jpg
if I remove the following line the page works fine.
session_set_save_handler("sess_open", "sess_close", "sess_read", "sess_write", "sess_destroy", "sess_gc");
I am guessing that this means that I have an error somewhere in the my code but I can't see anything. Any help would be much appreciated, thanks.
function sess_open($sess_path, $sess_name) {
return true;
}
function sess_close() {
return true;
}
function sess_read($sess_id) {
$result = dbQuery("SELECT data FROM sessions WHERE id = '$sess_id';");
if (!mysqli_num_rows($result)) {
$CurrentTime = time();
$result = dbQuery("INSERT INTO sessions (id, access) VALUES ('$sess_id', '$CurrentTime');");
return '';
} else {
extract(mysqli_fetch_array($result), EXTR_PREFIX_ALL, 'sess');
$result = dbQuery("UPDATE sessions SET access = '$CurrentTime' WHERE id = '$sess_id';");
return $sess_data;
}
}
function sess_write($sess_id, $data) {
$CurrentTime = time();
$result = dbQuery("UPDATE sessions SET data = '$data', access = '$CurrentTime' WHERE id = '$sess_id';");
return true;
}
function sess_destroy($sess_id) {
$result = dbQuery("DELETE FROM sessions WHERE id = '$sess_id';");
return true;
}
function sess_gc($sess_maxlifetime) {
$CurrentTime = time();
$result = dbQuery("DELETE FROM sessions WHERE access + $sess_maxlifetime < $CurrentTime;");
return true;
}
session_set_save_handler("sess_open", "sess_close", "sess_read", "sess_write", "sess_destroy", "sess_gc");
session_start();