How to check if a user is logged-in in php?

后端 未结 9 1586
南方客
南方客 2020-12-02 05:21

I\'m pretty new to php and I am trying to figure out how to use sessions to check and see if a user is logged into a website so that they would have authorization to access

9条回答
  •  时光取名叫无心
    2020-12-02 05:53

    you may do a session and place it:

    //start session
    session_start(); 
    
    //check do the person logged in
    if($_SESSION['username']==NULL){
        //haven't log in
        echo "You haven't log in";
    }else{
        //Logged in
        echo "Successfully log in!";
    }
    

    note:you must make a form which contain $_SESSION['username'] = $login_input_username;

提交回复
热议问题