我有几个被 ajax 调用来打印响应的页面,
这些页面使用$_SESSION
变量,所以我必须使用session_start()
. 我注意到页面有时会擦除会话数据(并且用户断开连接),我使用的有点不同 session_start()
:
function sec_session_start() {
$session_name = 'pentago'; // Set a custom session name
$secure = false; // Set to true if using https.
$httponly = false; // This stops javascript being able to access the session id.
ini_set('session.use_only_cookies', 1); // Forces sessions to only use cookies.
$cookieParams = session_get_cookie_params(); // Gets current cookies params.
session_set_cookie_params($cookieParams['lifetime'], $cookieParams["path"], $cookieParams["domain"], $secure, $httponly);
session_name($session_name); // Sets the session name to the one set above.
session_start(); // Start the php session
session_regenerate_id(true); // regenerated the session, delete the old one.
}
我的自定义session_start()
中有什么东西会导致响应页面删除会话吗?
谢谢你。