简体   繁体   English

如何解决$ _SESSION?

[英]How to troubleshoot $_SESSION?

I'm having an issue on my website I can't seem to troubleshoot. 我的网站上出现问题,似乎无法解决。 The site has a login that works fine, but the site sporadically logs users out. 该站点的登录正常,但是该站点偶尔会注销用户。

Steps: 1. Login 步骤:1.登录

  1. Use site (usually won't log you out right away) 使用网站(通常不会立即将您注销)

  2. Click on link (The links vary, doesn't seem to be isolated to a specific one) 单击链接(链接各不相同,似乎并不局限于特定链接)

  3. Get logged out 登出

The site has a 60-90 minute timer that is supposed to log people out, but for some reason I keep getting booted 5-30 minutes in. I have an MySQL_error function that reports errors but it doesn't report an error being present (otherwise I would post it). 该站点有一个60-90分钟的计时器,该计时器本应使用户注销,但是由于某些原因,我会不断启动5-30分钟。我有一个MySQL_error函数,该函数报告错误,但不报告存在的错误(否则我会发布它)。 This error has been present for quite a while and I can't figure out how to troubleshoot it very well at all. 这个错误已经存在了很长时间,我根本无法弄清楚如何对其进行故障排除。 I would be very grateful for any assistance! 我将非常感谢您的协助!

All of my pages use $_SESSION like so.... 我所有的页面都像这样使用$ _SESSION...。

if(isset($_SESSION['user_id'])) { insert page coding here } if(isset($ _ SESSION ['user_id'])){ 在此处插入页面编码 }

Else it logs you out. 否则它会将您注销。 I have noted this abnormality on multiple computers and I don't think it's based on my computer settings. 我已经在多台计算机上注意到了这种异常,并且我认为这不是基于我的计算机设置。

I had a similar problem once (see php $_SESSION variables disappear and reappear randomly ). 我曾经有过类似的问题(请参阅php $ _SESSION变量消失并随机重新出现 )。 It acted as if session variables would disappear randomly, and sometimes they also reappeared after some time. 它的作用就像会话变量会随机消失一样,有时它们在一段时间后也会重新出现。

I was eventually able to fix that problem by activating strict mode for sessions, adding this line right at the top of the page, above session_start(); 我最终可以通过激活会话的严格模式来解决该问题,并在页面顶部的session_start();上方添加此行session_start(); :

ini_set('session.use_strict_mode', 0);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM