0

これは構文の問題だと思いますが、いくつかの方法で試してみました。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 とともに示します。

4

1 に答える 1

0

POST データが正しいことを確認しましたか? 問題は、周囲のコードを見なくても、if ステートメント内のコードが実行されていない可能性があると思います。POST 変数「digest」が設定されていることを確認する必要があります。または、その if ステートメントの前に $_POST['digest'] と $_POST['uid'] を設定したかどうかをテストするために、var_dump が 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

            $_POST['digest'] = 'test';
    $_POST['uid'] = 1234;

            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;
}
于 2013-07-03T18:04:18.833 に答える