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

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

    WAMP server 2 - settings are not set by default for $_SESSION var.

    PHP.ini requires the following settings

    C:\wamp\bin\apache\apache2.4.2\bin\php.ini
    session.cookie_domain =
    session.use_cookies = 1
    session.save_path = "c:\wamp\tmp"   ;ensure the \ is used not /
    

    Session testing - load.php -- load $_SESSION var.

    <?PHP
    session_start();
    $_SESSION['SESS_MEMBER_ID'] = 'stored variable';
    session_write_close();
    header("location:print.php");
    ?>
    

    print.php -- print $_SESSION var.

    <?PHP
    session_start();
    var_dump($_SESSION);
    ?>
    

    run the script in your browser var_dump() should produce results

    go to c:\wamp\tmp Files containing the session data will appear here.

    0 讨论(0)
提交回复
热议问题