登录.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' 已创建,但变量中没有数据,另外两个中也没有数据。为什么?