dtpf76658 2011-02-11 01:23
浏览 41
已采纳

如何使用PHP会话使登录系统工作?

I am needing help with a somewhat simple task but I want to tackle this task so that it works on all browsers. My only problem is that I only have access to a Mac and no PC machines. So here is what I am needing to do:

I have a user area where people take quizzes. Some quizzes are longer than others and what is happening is that of a user completes the quiz quickly, the quiz is submitted and scored. However, if the user takes longer than 30 minutes to an hour for example, the quiz will not submit and it will kick the user back to my home page.

I am using PHP and SESSIONS for the users login data. I do not have any expiration date on my SESSIONS and I do not know why it is doing this. Do I need to switch to cookies? Or Can I add something to the SESSIONS to make so the user will NEVER be logged out until the click on the "Logout" link.

  • 写回答

2条回答 默认 最新

  • dongyuli0964 2011-02-11 01:46
    关注

    You can configure it on php.ini file, defining a global timeout for sessions.

    But, during application runtime, you can define it as a ini_set variable.

    Here, you can set a timeout of 90 minutes after last server request.

    ini_set('session.cache_expire',90);
    

    More about session ini, you can find here: http://www.php.net/manual/en/session.configuration.php#ini.session.cookie-lifetime

    You can extend this time ever request. I don't know about disable session expiration.

    But, as alternative, you can enable some polling on server to signalize an user interaction. i.e., some examples are found here: jQuery - polling of a job queue and here http://enfranchisedmind.com/blog/posts/jquery-periodicalupdater-ajax-polling/

    []'s,

    And Past

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥20 给自己本科IT专业毕业的妹m找个实习工作
  • ¥15 用友U8:向一个无法连接的网络尝试了一个套接字操作,如何解决?
  • ¥30 我的代码按理说完成了模型的搭建、训练、验证测试等工作(标签-网络|关键词-变化检测)
  • ¥50 mac mini外接显示器 画质字体模糊
  • ¥15 TLS1.2协议通信解密
  • ¥40 图书信息管理系统程序编写
  • ¥20 Qcustomplot缩小曲线形状问题
  • ¥15 企业资源规划ERP沙盘模拟
  • ¥15 树莓派控制机械臂传输命令报错,显示摄像头不存在
  • ¥15 前端echarts坐标轴问题