会话变量在新页面上丢失


Session variables lost on new page

我目前正在为一个客户端开发一个Web应用程序,其中Web空间托管在 one.com 上。

我已经实施了自己的安全登录系统,一切正常。当我登录某人时,变量可用,但是一旦我通过href转到新页面,我的所有会话变量都会丢失。我已经尝试了几乎所有关于类似问题的建议,但它不起作用。

我不能直接编辑我的php.ini这是标准的phpinfo:

我还不能嵌入图像,这是我的phpinfo

此外,在我调用的每个站点的开头

 ini_set("session.cookie_secure", 0);

因为一开始这(本地)总是设置为 true。

我使用以下代码在每个页面上启动一个安全会话:

$session_name = 'sec_session_id';   // Set a custom session name
$secure = true;
// This stops JavaScript being able to access the session$id.
$httponly = true;
// Forces sessions to only use cookies.
if (ini_set('session.use_only_cookies', 1) === FALSE) {
    header("Location: ../error.php?err=Could not initiate a safe session (ini_set)");
    exit();
}
// Gets current cookies params.
$cookieParams = session_get_cookie_params();
session_set_cookie_params($cookieParams["lifetime"],
    $cookieParams["path"], 
    $cookieParams["domain"], 
    $secure,
    $httponly);
// Sets the session name to the one set above.
session_name($session_name);
session_start();            // Start the PHP session 
session_regenerate_id(true);    // regenerated the session, delete the old one. 

我只是不明白为什么我的会话变量总是丢失。我会很高兴我能得到的每一个帮助!

编辑:有人建议最后一行:

session_regenerate_id(true);

可能导致问题,但删除后仍然不起作用。还能是什么?

我很

确定这条线(底线)是破坏会话的那条线:

session_regenerate_id(true);  // regenerated the session, delete the old one

删除该行,您的会话应该重新训练。