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.

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

报告相同问题?

悬赏问题

  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度