douyi7283 2015-04-02 15:24
浏览 73

PHP随机删除会话

On our PHP site (PHP 5.4.30), users are being logged out due to losing their PHP Session.

How to know the session is lost

   session_start();

   if (isset($_SESSION['version']) and file_exists($_SESSION['version'] . '/go.php')) {
        require $_SESSION['version'] . '/go.php';
   }
   else {
        session_destroy();
        header('HTTP/1.0 401 Unauthorized');
        header("Location: 401.php");
   }

Some investigations

  • The majority of users use Google Chrome.
  • There are no 404 issues (like favicons).
  • No cross-domain files are referenced.
  • No pages are likelier than others to lose sessions. Log in again, and the action you were performing in the system works again.
  • No PHP configuration is ever modified at runtime.
  • There is nothing funny going on in .htaccess (just protection and certain rewrites).
  • This only happens in the live environment (CentOS 5.1.1), not on dev machines.
  • There are no other blatant problems AFAIK, such as disk full or write errors to /tmp.

php.ini

php.ini content

/tmp

I have checked /tmp on the server and the session file is still there after being logged out

me@example.com [/tmp]# dir -l sess_abcdefb967fc79364a5a773e0157d663
-rw------- 1 si si 565 Apr  3 09:51 sess_abcdefb967fc79364a5a773e0157d663

Headers

A typical pageview results in a header like:

General
Remote Address:123.123.171.111:443  
Request URL:https://example.com/mx/TypicalPage  
Request Method:GET  
Status Code:200 OK  

Response Headers 
Cache-Control:private  
Connection:Keep-Alive  
Content-Length:6716  
Content-Type:text/html; charset=UTF-8  
Date:Fri, 03 Apr 2015 20:43:06 GMT  
Expires:Thu, 19 Nov 1981 08:52:00 GMT  
Keep-Alive:timeout=5, max=100  
Pragma:no-cache  
Server:Apache/2.2.27 (Unix) mod_ssl/2.2.27 OpenSSL/0.9.8e-fips-rhel5   mod_bwlimited/1.4 PHP/5.4.30  
X-Powered-By:PHP/5.4.30  

Request Headers
Accept:text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
Accept-Encoding:gzip, deflate, sdch  
Accept-Language:en-US,en;q=0.8,de;q=0.6,pt-BR;q=0.4,pt;q=0.2  
Connection:keep-alive  
Cookie:PHPSESSID=1234567890abcdef1234567890abcdef  
Host:simplement.com.br  
Referer:https://example.com/mx/PreviousPage  
User-Agent:Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/43.0.2356.0 Safari/537.36
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 R语言Rstudio突然无法启动
    • ¥15 关于#matlab#的问题:提取2个图像的变量作为另外一个图像像元的移动量,计算新的位置创建新的图像并提取第二个图像的变量到新的图像
    • ¥15 改算法,照着压缩包里边,参考其他代码封装的格式 写到main函数里
    • ¥15 用windows做服务的同志有吗
    • ¥60 求一个简单的网页(标签-安全|关键词-上传)
    • ¥35 lstm时间序列共享单车预测,loss值优化,参数优化算法
    • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
    • ¥100 为什么这个恒流源电路不能恒流?
    • ¥15 有偿求跨组件数据流路径图
    • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值