的login.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);
}
的index.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'已创建,但变量中没有数据,另外两个中也没有数据。为什么呢?
答案 0 :(得分:1)
使用var_dump
检查SESSION变量。如果它输出你期望的数据,可能你的语法错误了。
示例强>
var_dump($_SESSION['bbzalinusrnmenstr']);