Facebook / IE8 - Session is not being persisted
I have a Facebook iFrame application (written in PHP) and when I run it in IE8, my session data is not persisted.
I'm using Symfony 1.4 and have tried both Symfony's session wrapper and $_SESSION.
I set up two test pages: the first one defines $_SESSION['foo'] = 'bar' and calls print_r($_SESSION). The second page also calls print_r($_SESSION). I see my session variables set on the first page, but not on the second.
Everything works fine in Firefox and Chrome, and I've had two other people test this on different PCs running IE8 and they have the same problem.
Any help would be greatly appreciated, thanks!
After some more research, this is a specific problem with Facebook iframe apps and Internet Explorer. Luckily, the solution is very simple, I just needed to add this code header('P3P: CP="CAO PSA OUR"'); Everything works fine now!
After even more research, this problem isn't specific to Facebook, just iframes. It has to do with third party cookies and how Internet Explorer (and Safari) handle them. I want to note that the header code works for IE, but not Safari.
I was having this same problem. PHP sessions were not persisting IE8, but they were in every other browser (Chrome, Firefox, Opera, Safari). Nothing worked. I tried everything from proper headers with P3P directives, cookie manipulation, resetting session id's, setting cookies to expire way in the future, blah, blah, blah.
Here is what finally worked (and I don't know why it works), but this was the culprit...
After days of debugging, I found that my script had an image tag that had a bad src reference in it, like this:
In other words, the src reference was empty/blank. THIS WAS THE CULPRIT TO MY WHOLE PROBLEM. I don't know why, but after putting in an actual image location like this:
After correcting the empty src reference, everything worked fine and the PHP session was being set properly even in IE8. Believe or not, this was the reason behind the PHP session not being set.
I still have no idea but it worked fine after this. I'll have to research why this would cause a problem like this. If anyone knows why, please post the answer.
I hope this helps someone. :-)