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

后端 未结 7 921
长情又很酷
长情又很酷 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:33

    After a long time I have fixed this bug finally.

    On my localhost WAMP, the session data is not saved between page loads, because the session data is stored in a cookie, and there is no cookie domain to be set for localhost.

    The solution:

    'session.cookie_domain' should be set to empty string for all local domain names, not only for 'localhost' (but should not be empty for local IP addresses):

    
    

    Thanks to Marcin Wiazowski who posted it here.

提交回复
热议问题