I am experiencing a very weird behavior with PHP and session.
The script that I am using has been working for months and it is working on various servers with various PHP versions.
the script read the URL and re-route depending on the URL, for example hitting /offer/abc1234.html it will call the class offer and pass abc1234 as parameter.
I have created a "failover" class that in other words if you write /abc1234.html it will test various database entries and if it finds one automatically include that class like if it was called by URL with just a bit of extra overhead, the difference is:
- /offer/abc1234.html :: index.php -> offer.php -> home.php
- abc1234.html :: index.php -> error.php -> failover.php -> offer.php -> home.php
Now, given that this all works and has been working for months my problem is with sessions.
if I hit /offer/abc1234.html I see the session set and the cookie sent to the browser
if I hit /abc1234.html the session is set correctly, no errors (E_STRICT+E_ALL), no warning, no nothing, but the cookie is not sent to the browser. I even tried to print the $_SESSION at the end of the script, and the session is populated and all the vars are correct except the headers.
I have tried to debug it and add various var_dump in various places, but nothing is different anywhere except the header_list() never contains the session_cookie but it does contain other cookies that I manually set:
I currently print:
- session_name()
- session_id() - this changes at each refresh but it is consistent on the whole page
- session_get_cookie_params()
- headers_list() - this does not contains the set-cookie header that session_start should have
the output is something like:
- string(6) "QSCSID"
- string(26) "456disv3pl4u2j81dej6h6d717"
- array(5) { ["lifetime"]=> int(0) ["path"]=> string(1) "/" ["domain"]=> string(0) "" ["secure"]=> bool(false) ["httponly"]=> bool(false) }
- array(4) { [0]=> string(38) "Expires: Thu, 19 Nov 1981 08:52:00 GMT" [1]=> string(77) "Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0" [2]=> string(16) "Pragma: no-cache" [3]=> string(68) "Set-Cookie: spi=17468; expires=Sat, 26-Oct-2013 05:02:23 GMT; path=/" }
Again, I am getting crazy as everything was working earlier in the day, then I restarted apache and it stopped working.
I have checked the server, and the folder is not full and it is writable and the files get created and are empty when I call abcd1234.html
EDIT
while working on it, I start to open the files via "ee" (FreeBSD editor) directly on the server. Nothing happened until I opened/saved a class, no changes were made on the file, I accidentally added a space and removed it, then when I exited the editor asked me to save and I said YES.
PHP is compiled with eaccelerator, I had already removed the cache folder as well as re-restarted apache and saw the folder autopopulate. Such class (the failover.php) is a simple 4 function where each function is a query, then the construct call each function one at the time.
So, it seems working, but I would like to know if anyone ever experienced something like this and if they knew what the issue might have been