duanluangua8850 2010-06-22 11:30
浏览 57
已采纳

session_set_save_handler wamp崩溃

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();
  • 写回答

1条回答 默认 最新

  • dongzipu7517 2010-06-22 11:42
    关注

    That is a bug in the httpd, not in your code. Or, rather, it is surely caused by your code, but apache shoud never crash like that (you should get PHP errors, while here it is just crashing the server). Try updating wamp, or try to install xampp and check if you can get a more meaningful error.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?