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.

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

报告相同问题?

悬赏问题

  • ¥15 随身WiFi网络灯亮但是没有网络,如何解决?
  • ¥15 gdf格式的脑电数据如何处理matlab
  • ¥20 重新写的代码替换了之后运行hbuliderx就这样了
  • ¥100 监控抖音用户作品更新可以微信公众号提醒
  • ¥15 UE5 如何可以不渲染HDRIBackdrop背景
  • ¥70 2048小游戏毕设项目
  • ¥20 mysql架构,按照姓名分表
  • ¥15 MATLAB实现区间[a,b]上的Gauss-Legendre积分
  • ¥15 delphi webbrowser组件网页下拉菜单自动选择问题
  • ¥15 linux驱动,linux应用,多线程