PHP Session not Saving

前端 未结 9 1112
情话喂你
情话喂你 2020-12-03 17:39

I have this written at the very first line on every page of my website.

include(\"restd.php\");

and restd.php contains the following lines

9条回答
  •  余生分开走
    2020-12-03 17:49

    I had the same problem and found a work-around for it. If anybody can explain why the session is not read even when the cookie is there, please let me know.

    
    
    
    
    
    

    .

    [EDIT]

    Even though the cookie was there and I prevented starting a new session, the session had not been read and started, so no session variables were available. In this case I check if the session has been started first (not using session_status() because it doesn't exist in PHP 3.5, which for some reason is the most widespread among hosts). If no session has been started within PHP, I check if it had been started before by testing the cookies and GET variables. If a session ID was found, the script resumes the session with that ID. If no ID is available, the user gets redirected to the index.

提交回复
热议问题