gpt4 book ai didi

php - SESSION 变量在需要 SIMPLESAMLPHP 后不起作用

转载 作者:行者123 更新时间:2023-12-02 03:34:06 27 4
gpt4 key购买 nike

我的 session 变量有问题。

我无法在请求一次后设置任何变量。但是我需要在登录后存储我的数据。

代码如下:

<?php include "include/header.php";

require_once('simplesamlphp/lib/_autoload.php');
$as = new \SimpleSAML\Auth\Simple('default-sp');

$as->requireAuth();

$attributes = $as->getAttributes();

$_SESSION["nivauth"] = "test";

?>

编辑:

  • session_start() 在 header.php 中
  • 我尝试使用 echo $_SESSION["nivauth"];
  • 在另一个页面上获取 session 变量

我在另一页上有这个错误:
注意:未定义索引:/var/www/html/cableEdit.php 第 10 行中的 nivauth

我的 session var nivauth 仅在我的第一页上可用。

我的 session_start() 可以正常运行,可以查看我在其他页面上创建的所有其他 session 变量。

如果我将 $_SESSION["nivauth"] = "test"; 放在 include 下,一切正常,但我无法从身份验证中获得 nivauth。

var 已创建但无法在其他页面上访问...

最佳答案

引用this part of the documentation

If we are using PHP sessions in SimpleSAMLphp and in the application we are protecting, SimpleSAMLphp will close any existing session when invoked for the first time, and its own session will prevail afterwards. If you want to restore your own session after calling SimpleSAMLphp, you can do so by cleaning up the session like this:

$session = SimpleSAML_Session::getSessionFromRequest();
$session->cleanup();

If you don't cleanup SimpleSAMLphp's session and try to use $_SESSION afterwards, you won't be using your own session and all your data is likely to get lost or inaccessible.

关于php - SESSION 变量在需要 SIMPLESAMLPHP 后不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50853352/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com