How to disable PHP session cookie?

后端 未结 6 2155
醉梦人生
醉梦人生 2020-12-11 03:30

I am writing PHP code where I want to pass the session id myself using POST. I don\'t want a cookie to store the session, as it should get lost when the user gets out of the

6条回答
  •  抹茶落季
    2020-12-11 03:41

    The way to do it is to setup sessions yourself.

    In the central include file that all your other files are including (you do have one of those, right?), you need to do a few things as early as is practical.

    if( !array_key_exists('sessionid', $_POST) ) {
        // recreate the sessionid
        $sessionid = md5(rand().' '.microtime()); // Or something
    } else {
        $sessionid = $_POST['sessionid'];
    
    session_id($sessionid);
    session_start();
    

    Now you have to remember that as soon as you start the form, you need to include:

    
    

提交回复
热议问题