【问题标题】:CakePHP Session Timeout Not as Programmed?CakePHP 会话超时没有按程序设计?
【发布时间】:2017-12-04 22:44:59
【问题描述】:

我在 CakePHP 中遇到的会话超时比我编写代码的速度更快。我有这一行:

'Session' => [
    'defaults' => 'php',
    'timeout'=>24*60*60*30//for one month
],

....但我相信它正在退出大约 30 分钟的不活动状态,至少感觉在那里。

知道如何解决此问题或调查问题出在哪里吗?

谢谢!

【问题讨论】:

  • 检查您的会话 cookie 过期日期,它可能在服务器上的会话实际超时之前过期。还要确保ini_set() 被允许,因为CakePHP 需要修改session.gc_maxlifetime 值,它被读回并用于确定不活动超时。 ps,请务必提及您的 准确 CakePHP 版本(vendor/cakephp/cakephp/VERSION.txtlib/Cake/VERSION.txt 中的最后一行)-谢谢!

标签: php session cakephp cookies session-cookies


【解决方案1】:
'Session' => [
'cookie'=>'webapp',
'timeout' => 4320,
'cookieTimeout'=> 4320
],

【讨论】:

    【解决方案2】:

    php 不是最强大的默认值:

    The built in defaults are:
    
    - 'php' - Uses settings defined in your php.ini.
    - 'cake' - Saves session files in CakePHP's /tmp directory.
    - 'database' - Uses CakePHP's database sessions.
    - 'cache' - Use the Cache class to save sessions.
    

    我会改用cake,这样您就可以拥有自己的会话目录。这样,过期时间较短的其他应用不会删除您的会话文件。

    【讨论】:

      【解决方案3】:

      试试这个:

      'Session' => [
          'defaults' => 'php',
              'timeout' => 24*60*60*30, // The session will timeout after 30 minutes of inactivity
              'cookieTimeout' => 1440, // The session cookie will live for at most 24 hours, this does not effect session timeouts
              'checkAgent' => false,
              'autoRegenerate' => true, // causes the session expiration time to reset on each page load
      ],
      

      【讨论】:

        猜你喜欢
        • 2013-12-19
        • 2011-12-29
        • 2011-05-09
        • 1970-01-01
        • 2017-06-10
        • 2018-08-10
        • 2013-06-18
        • 2019-09-27
        • 1970-01-01
        相关资源
        最近更新 更多