0

我相信我这样做是正确的,但它没有获取存储的 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// ?> 

在所有页面上设置会话开始

4

1 回答 1

1

您没有session_start()在 index.php 上使用

打完电话后ob_start()你打ob_end_clean(), ob_end_flush(), ob_clean(), 还是ob_flush()?

于 2012-07-01T00:11:56.573 回答