duanjue7745 2017-12-12 20:24
浏览 64

PHP MySQL的会话超时问题

I have a site where the users sometimes need over an hour to fill out forms and submit to mysql. I've adjusted the session.gc_maxlifetime to 7200 (2 hrs) and verified cookie timeout is 0 for never. The website still sends them back to the login page after the default 24 minutes without saving their data. I've added session_start() to index and my head.php for all other pages to see via include. any help would be awesome. Hosted on godaddy, so I cannot modify the php.ini, they had me modify .user.ini. when I echo the information it shows correctly.

SESSION START-<?php echo $_SESSION['time']; ?> Displays time user logged in.
SESSION TIMOUT-<?php echo ini_get('session.gc_maxlifetime'); ?> Displays 7200 
SESSION COOKIE-<?php echo ini_get('session.cookie_lifetime'); ?> Displays 0

<?php
function error_found(){
header("Location: inc/records.php");
}
$lifetime=0;
session_set_cookie_params($lifetime);
ini_set('session.gc_maxlifetime', 7200);
session_start();

header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Cache-control: no-cache");
header("Pragma: no-cache");

ob_start();

Note: When refreshing the pages, submitting forms, or any other navigation, the session_start() does not update. Could that be the issue?

  • 写回答

1条回答 默认 最新

  • doumeng3345 2017-12-14 18:48
    关注

    With the help of Marek here is my solution. create new folder for save path. verify permissions are not set to read-only. set phpini.ini or .user.ini in each folder to:

    session.gc_maxlifetime = 7200 \\ Seconds you want. I set to 2 hrs.
    session.gc_divisor = 1 
    session.save_path = /home/folder/public_html/site.com/Your_new_folder
    
    评论

报告相同问题?

悬赏问题

  • ¥15 微信公众号自制会员卡没有收款渠道啊
  • ¥15 stable diffusion
  • ¥100 Jenkins自动化部署—悬赏100元
  • ¥15 关于#python#的问题:求帮写python代码
  • ¥20 MATLAB画图图形出现上下震荡的线条
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘
  • ¥15 perl MISA分析p3_in脚本出错
  • ¥15 k8s部署jupyterlab,jupyterlab保存不了文件
  • ¥15 ubuntu虚拟机打包apk错误
  • ¥199 rust编程架构设计的方案 有偿