1

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 !

Community
  • 1
  • 1
Zorro07
  • 21
  • 1
  • 8
  • You 'update' but that term is a bit vague. You could try to bypass the cache: https://en.wikipedia.org/wiki/Wikipedia:Bypass_your_cache#Google_Chrome – KIKO Software Apr 09 '17 at 07:58
  • Does your "shared server" any load balancing? The described behaviour sounds like a incorrect configuration of load balancing. – seboettg Apr 09 '17 at 08:41
  • @ KIKO I do not think it is a cache issue because the response include Cache-control: no-store, no-cache – Zorro07 Apr 09 '17 at 16:02
  • @seboettg I am on a shared server at OVH.com so I have no way to answer your question.Do you think it is a server problem? – Zorro07 Apr 09 '17 at 16:04
  • yes, I think so. – seboettg Apr 10 '17 at 16:14

0 Answers0