且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

PHP会话超时过快

更新时间:2023-12-04 21:02:28

随机到期是会话数据目录的经典症状,该会话数据目录由多个应用程序共享:session.gc_maxlifetime时间最短的会话很可能会从其他应用程序中删除数据.原因:

Random expiration is a classical symptom of session data directory shared by several applications: the one with the shortest session.gc_maxlifetime time is likely to remove data from other applications. The reason:

  1. 默认情况下,PHP将会话文件存储在系统临时目录中.
  2. 内置文件处理程序不跟踪谁拥有哪个会话文件(它仅将文件名与会话ID匹配):

  1. PHP stores session files in the system temporary directory by default.
  2. The builtin file handler doesn't track who owns what session file (it just matches file name with session ID):

我的建议是,为应用程序配置私有自定义会话目录.可以使用 session_save_path()函数或设置

My advice is that you configure a private custom session directory for your application. That can be done with the session_save_path() function or setting the session.save_path configuration directive. Please check your framework's documentation for the precise details on how to do it in your own codebase.