session_start();
//Yes i did call session start but forgot to add it here
print $userID.":::";
$_SESSION['id'] = $userID;
$_SESSION['email'] = $userEmail;
$_SESSION['password'] = $userPassword;
$_SESSION['picture'] = $userProfilePicture;
print "ID: ".$_SESSION['id'];
结果: 1 ::: ID:
我无法将任何变量分配给我的代码中的会话变量,为什么会这样?我以前做过,代码是相同的,除了变量
答案 0 :(得分:4)
为了让会话在PHP页面上工作,你必须调用session_start();功能位于您要访问会话的每个页面的顶部。