php session is not stored in chrome
This is a known issue in Chromium. Issue 114877
Place a favicon in the root folder, and this should correct your issue.
Salvador Dali
I am a Software Engineer in the Google Search Growth team. I use Tensorflow and TFX to analyze search data and Go to write data pipelines. This is my personal profile which has absolutely nothing to do with my employer.
Updated on June 04, 2022Comments
-
Salvador Dali almost 2 years
I have not worked with php for some time and came back to one of my projects just to find out that the session variable is not stored. It came like a surprise, because the last time I checked, it worked and I have not used php (therefore has not changed the code or config).
The situation is as follows: session is not stored across the pages (I can save it and it shows the same on the page, but when I refresh - nothing changes).
I looked here PHP Session data not being saved and replicated the example:
<?php session_start(); if(isset($_SESSION['views'])) $_SESSION['views'] = $_SESSION['views']+ 1; else $_SESSION['views'] = 1; echo "views = ". $_SESSION['views']; echo '<p><a href="page1.php">Refresh</a></p>';
but nothing changes: I still has views = 1.
Nevertheless I have not changed my config, but I still looked at phpinfo():
I checked my permissions to write to the folder /tmp - they are ok, moreover after each refresh a new file appears there.
Then I checked the work in other browsers: and to my surprise it works in firefox: the number correctly increases there.
So the situation: in chrome it does not work, in firefox it works. I use chrome as default. I also remember playing with chrome options when it switches to blink, but as far as I remember I changed back everything.
Any idea how I can fix php sessions in chrome?
P.S:
- cookies are enabled in chrome
- sessions files are in /tmp I tried to delete them all and when later I refresh the page in chrome - the new file appears
- in headers I am sending Cookie:PHPSESSID=mystring but no session id
-
nl-x almost 11 years@SalvadorDali Uhm, looking at your phpinfo... Should your session_cache_expire be 0 ?! Try putting it back to 180 (the default). You can try doing it in code, without editing php.ini , by placing
session_cache_expire(180);
beforesession_start();
. The manual specified no default behaviour for setting session.cache_expire to 0, so it might really mean 0 minutes. -
nl-x almost 11 years@SalvadorDali But just to doublecheck: FireFox and IE do work ? And in the developer tools you see the page being loaded and getting a 200 - OK ? (Not that it is being served from the cache.)
-
Nanne almost 11 yearsbut the default should work, and to change to other storage just because this isn't working is a bit awkward...
-
Nikola Petkanski almost 11 yearsI've mentioned a consideration based on my experience with using sessions. I think there is no experienced php developer who would prefer to save its sessions into the default tmp folder.
-
Nikola Petkanski almost 11 yearsNote that this is just an advice - it won't fix the issue he complains about. The solution I gave is to try
session_write_close()
. -
Nikola Petkanski almost 11 yearsHow's that a fix for the question:
Any idea how I can fix php sessions in chrome?
-
Amir almost 11 yearscokies send by the PHP server to the browser and it saves in
session.save_path
, but perhaps your browserchrome
have not access to the path -
PeerBr about 9 yearsThe
save_path
relates to where the PHP stores the physical file for the session on the server. No browser will have access to that path. -
Amir about 9 years@PeerBr, cookie (contain session_id) stores in client side and session data stores in server side at
session.save_path
. it is better to not change this path. -
Mehmet Soylu almost 5 yearsyes. unfortunately if you add favicon, you and your users have to visit website for favicon update. chrome history cannot resolve the new favicon from extension.