Php会话未在下一页显示

时间:2016-08-28 03:57:11

标签: php mysql session hosting vps

我的会话管理员未显示在第二页上。我和godaddy有一个VPS。我尝试使用session.save_path将会话保存在不同的文件夹中,但这不起作用。

Page1.php

<?php session_start();

    error_reporting(E_ALL);

    $username = $_POST['username'];
    $password = $_POST['password'];

    $mysqli = new mysqli("***","***","***!", "***");
    $query = "SELECT * FROM admin WHERE username = '$username' AND password = '$password'";
    $result = $mysqli->query($query);

    if(isset($_POST['submit'])) {
        if($mysqli->connect_error) {
            echo "Could not connect";
        } else {
            if(mysqli_num_rows($result)) {
                $_SESSION["admin"] = $_POST['username'];
                $mysqli->close();
                echo "<script>window.location = 'http://www.ctinvest.net/welcome.php';</script>";
            } else {
                echo "user not found ";
            }
        }
    }
?>

使page2.php

    <?php session_start();

    echo $_SESSION["admin"];

    error_reporting(E_ALL);

    if(!isset($_SESSION["admin"])) {
        echo "Administrative access only";
        die();
    } else {

    }

    if(isset($_POST['submit'])) { //log out
        session_destroy();
        setcookie("address","", time()+1);
        setcookie("prop","", time()+1);
        echo "<script>window.location = 'http://www.ctinvest.net/';</script>";
    }

?>

0 个答案:

没有答案