PHP SESSION data lost between page loads with WAMPserver 2.0 on localhost

后端 未结 7 917
长情又很酷
长情又很酷 2021-01-15 02:08

I have a PHP authentication system on my website using the $_SESSION variable.

A form submits a username and password to the file \"login.php\". It is handled like t

7条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-01-15 02:43

    Try to replace

    if($_POST){...}
    

    with

    if( isset($_POST['username']) && isset($_POST['password']) ){...}
    

    ... at least for debugging purposes. It's possible that some different settings are causing a non-empty $_POST array where it's not expected.

    Also, your code seems to be missing exit() calls after header() redirections. Sending an HTTP Location header doesn't automatically stop your script.

提交回复
热议问题