我认为这是一个语法问题,但我已经尝试了几种不同的方法。在 IIS 6 上运行的 PHP 5.4.16(这些不是我的选择)。
我无法将 $usr 设置为 $_SESSION['uid']。我在设置后立即运行了转储,我看到了会话数据的 uid 信息,但 $usr 为 NULL。语法错误?你认为发生了什么?
function User_CustomValidate(&$usr, &$pwd) {
session_start(); // Initialize Session data
ob_start(); // Turn on output buffering
$appKey = "pwssssssssssssss";
$safeurl = 'https://safe.ssssss.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'];
var_dump($usr, $_SESSION['uid']);
$this->setCurrentUserName($usr);
return TRUE;
}
因此 var_dump 显示 $usr = NULL 和 $_SESSION['uid'] 以及 SSO 传递的正确员工 ID。