I have a very strange problem. I am using this simple code:
<?php
session_start();
if(isset($_SESSION['test'])) {
echo $_SESSION['test']."<br>session:".session_id();
}
else {
echo "<h1>Session inexistante. Crée</h1>";
$_SESSION['test']=2;
}
?>
1- I delete all cookies, session, cache...
2 - I go to my page and get the message "Session inexistante. Crée" (meaning "Session does not exist. Created"). This is normal
3 - I update this page, and I still get the message "Session inexistante. Crée". This is not normal !
4 - I update again and the session works correctly
Here are screenshots with the detail of HTTP requests
- We see that on the first loading the session does not exist and is requested by Chrome
- On the second loading Chrome makes a correct request giving the PHPSESSID, the response is correct because it does not contains an other PHPSESSID so it seems PHP is happy with this PHPSESSID. But the message displayed is still "Session inexistante. Crée" !
- We see on the third loading that the session ID given by PHP during the first load of the page was correct. So why it has not been recognised on the second loading?
I am using Php5.6 on a shared server.
This issue is rather random. I have no difficulty to reproduce it even if somethimes everything works well. Sometimes the issue is on the third loading.
This issue is more general on my website. Many users with many browsers have a similar issues.
There is a similar problem here: but as you see I have no 404 error or 302 redirect.
Thank you for your help !