我正在重新编写许多登录脚本,并在我们的一个内部网站上运行了一个像这样设置的大型函数文件。
- 类
- 功能
- 功能
- 类
- 类
- CLASS验证用户
- 类
- 类
我运行了一个脚本,用于检索SSO $_SESSION
数据,并希望将其从SSO服务器传递到用户的会话。
我试过在文件的不同部分运行脚本,但得到了相同的结果。它在某些地方有效,而在其他地方无效。
我可以将所有的$_SESSION
变量回显到HTML页面。
我也可以在某些类中使用$_SESSION
数据(无论我把它放在哪里,都是一样的)。
然而,我真正需要使用的类——验证用户——所有内容都为null。
我是不是遗漏了什么(请不要告诉我放session_start();
)。
我认为$_SESSION
数据是超全局的。检索到的$_SESSION
数据也是超全局的吗?
如果没有,我需要做些什么才能使其超全球化?
这是我用来检索会话数据以传递的脚本-
session_start();
$appKey = "00000000Uz";
$safeurl = 'https://safe.000000.com/login/sso/SSOService?app=playbooks';
// first call back after safe login - POST is set
if ($_POST && isset($_POST['digest']))
{
$digest = $_POST["digest"];
// set the session variables ...
$_SESSION['usernames'] = $_POST["firstname"]." ".$_POST["lastname"];
$_SESSION['firstname'] = $_POST["firstname"];
$_SESSION['lastname'] = $_POST["lastname"];
$_SESSION['email'] = $_POST["email"];
$_SESSION['uid'] = $_POST["uid"];
// Needed for key
$uid = $_POST["uid"];
$time = $_POST["time"];
// Read the property file with the key and URL so this won't go into the main code
// this sets $appKey and $safeurl
$mykey = "".$uid.$time.$appKey;
$mydigest = md5($mykey);
}
// session is not initialized as we never got the post above to set session vars
// call now the safe login to get the post to set the session vars ...
if (!isset($_SESSION['uid']) || empty($_SESSION['uid']))
{
// Read the property file with the key and URL so this won't go into the main code
// this sets $appKey and $safeurl
header("Location: ".$safeurl);
}
$usr = $_SESSION['uid'];
$this->setCurrentUserName($usr);
return TRUE;
}
确保在使用$_SESSION
之前调用session_start()
。