php session doesn't work

前端 未结 8 734
余生分开走
余生分开走 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条回答
  •  萌比男神i
    2021-01-22 19:08

    Use one for action document such as index.php there is code:

    session_start();
    if(isset($_POST['login']) && isset($_POST['password'])){
       // login
       header('Location: (here is some page)');
    }
    if(!isset($_SESSION['user']){
      // @todo some action
    } else {
      require_once('login.php');
    }
    
    if(isset($_GET['logout'])){
       unset($_SESSION['user']);
       header('Location: (here is some page)');
    }
    

提交回复
热议问题