我相信我这样做是正确的,但它没有获取存储的 cookie 信息
登录.php
session_start();
$_SESSION['username'] = $user;
$_SESSION['password'] = $pass;
if(isset($_POST['remmemberme']))
{ ob_start();
setcookie("kitbusername", $_SESSION['username'], time()+60*60*24*100);
setcookie("kitbpassword", $_SESSION['password'], time()+60*60*24*100);
echo '<script>
window.top.location.href = "index.php";
</script>';
}
索引.php
<p class="welcome">Hello
<?php
session_start();
if($_COOKIE['kitbusername']){echo $_SESSION['username'];}
elseif($_SESSION['username']){
echo $_COOKIE['kitbusername'];
} else{
echo 'Guest';
}?>
</p>
头文件.php
<?php session_start();
if(isset($_SESSION['username']) || isset($_COOKIE['kitbusername'])){
//Log Out Button// ?>
在所有页面上设置会话开始