检查PHP.php:
<?php
session_start();
if ($_SESSION['loggedIn'] == "no") {
echo "not logged in";
}
else if ($_SESSION['loggedIn'] == "yes") {
echo "logged in";
}
else if (!isset($_SESSION['loggedIn'])){
echo "session not set";
}
?>
<html>
<form id = "form2" method="post" action="checklogin2.php">
Email:<br />
<input type="text" name="myusername" size = "35"/><br />
Password:<br />
<input type="text" name="mypassword" size = "35" /><br />
<input type="submit" value="Login" /><br />
</form>
</html>
checklogin2.php:
<?php
session_start();
$_SESSION['loggedIn'] = "yes";
header("location:checkPHP.php");
?>
我第一次加载页面时,未设置会话。但是当我登录时,假设将其设置为yes,然后将用户重定向回主页。然而,这两次它只是说会话没有设置。所以我想我不确定如何正确设置会话。谢谢!