0

登录.php

$login=Pbkdf2::login($password, $hashpwd, $salt);
if($login)
{
session_start();
$_SESSION['bbzalinusrnmenstr'] =base64_encode($username);
$_SESSION['actualname'] =base64_encode($name);
$_SESSION['useremail'] =base64_encode($email);
$send=array('username'=>$username, 'callingname'=>$name, 'email'=>$email);  
echo json_encode($send); 
exit;
}

else
{
$send=array('error'=>"Mismatching credentails.");  
echo json_encode($send);
}

索引.php

session_start();
$logged=0;
if(isset($_SESSION['bbzalinusrnmenstr']))
{
    $logged=1;
    $username=$_SESSION['bbzalinusrnmenstr'];
    $username=base64_decode($username);
        $actualname=$_SESSION['actualname'];
        $useremail=$_SESSION['useremail'];

        echo "$actualname logged in with $username as his Username and $useremail as his email address";
}

这将输出以他的用户名和他的电子邮件地址登录

SESSION 'bbzalinusrnmenstr' 已创建,但变量中没有数据,另外两个中也没有数据。为什么?

4

1 回答 1

1

用于var_dump检查 SESSION 变量。如果它输出您期望的数据,那么您的语法可能在某处做错了。

例子

var_dump($_SESSION['bbzalinusrnmenstr']);

于 2013-08-08T16:43:31.433 回答