php session doesn't work

前端 未结 8 544
余生分开走
余生分开走 2021-01-22 18:57

How it should work: Index.php is the secured page. It includes check.php, which checks if you have a session = good. If it hasn\'t, you\'re not logged in -> log off, remove sess

8条回答
  •  遥遥无期
    2021-01-22 19:05

    if($count==1){
        session_start();    
        $_SESSION['Username'] = $UserName;
        $_SESSION['Password'] = $password;
        UpdateOnlineChecker($Session);
        header( "Location: http://". strip_tags( $_SERVER ['HTTP_HOST'] ) ."/newHolo/" );
        exit;
    }
    else {
        echo "Wrong Username or Password";
    }
    

    Look at my code. It checks if the statement is true (for me, if there is one row with a query statement i execute). Then i start a session and basically Ill define global session variables, sned out a query to my database to update the session and then refer through.

    you are missing a session_start(); in your if true block.

提交回复
热议问题