dtiopy6088 2011-09-20 18:04
浏览 7
已采纳

如果我不希望会话死亡,我应该更改哪个apache2 / php5配置?

I'm logging my admin like this:

session_start();
$_SESSION['admin'] = TRUE;

When I login and stay inactive for like 10 minutes, then refresh, the session is dead and the admin is logged out.

What do I need to set either in htaccess or in the php file itself so that the session stays alive for at least 8 hours?

  • 写回答

3条回答 默认 最新

  • doutang3760 2011-09-20 18:16
    关注

    Create a file and put <?php phpinfo() ?> in it and check the output.

    The value you want to look at is session.cookie_lifetime and session.gc_lifetime.

    gc_maxlifetime specifies the number of seconds after which data will be seen as 'garbage' and potentially cleaned up. Garbage collection may occur during session start (depending on session.gc_probability and session.gc_divisor).

    In your script that is responsible for starting the sessions, you can put ini_set('session.gc_maxlifetime', 3600); // set session data life to 1 hour or any other time that is suitable for your application.

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

报告相同问题?

悬赏问题

  • ¥15 Vue3 大型图片数据拖动排序
  • ¥15 划分vlan后不通了
  • ¥15 GDI处理通道视频时总是带有白色锯齿
  • ¥20 用雷电模拟器安装百达屋apk一直闪退
  • ¥15 算能科技20240506咨询(拒绝大模型回答)
  • ¥15 自适应 AR 模型 参数估计Matlab程序
  • ¥100 角动量包络面如何用MATLAB绘制
  • ¥15 merge函数占用内存过大
  • ¥15 使用EMD去噪处理RML2016数据集时候的原理
  • ¥15 神经网络预测均方误差很小 但是图像上看着差别太大