我正在尝试管理活动的 php 会话:
描述:
我有自定义的 php 页面,它们都在顶部:
<?php
include 'session_handler.php';
?>
文件“session_handler.php”具有以下内容:
<?php
if (!defined('copyright_files')){
header("Location:error.php");
exit();
}
?>
<?php
session_name("sessionhash");
session_start();
error_reporting(E_ALL);
include 'connect.php';
?>
我正在使用 json 从页面中获取数据,并通过 ajax 请求内容。
我还通过 ajax(在背景中)定期调用“checksession.php”,例如:每 5 秒。
问题:
问题是我意外地失去了会话。
之前的“session_handler.php”有:
<?php
session_name("sessionhash");
session_start();
session_regenerate_id(true);
error_reporting(E_ALL);
include 'connect.php';
?>
这是为相同的创建更多会话,所以我删除了“session_regenerate_id”,它现在只使用一次。
我在 .htaccess 中使用以下内容
php_value session.cookie_lifetime 18000
php_value session.gc_maxlifetime 18000