Fixing IE7 dropping PHP Sessions

After banging my head against the wall, and spending the better part of today trying to find out why my session variables were not being transferred from page to page in IE7, it worked fine in Firefox and Safari. The sessions not working were rendering MySpace OpenSocial App in Iframe and was dead to anyone using IE7. But the good news is i got it fixed (thanks to google), and the fix is so simple it’s ridiculous.  Before you start your session, you need to declare a privacy policy in your header.

header('P3P: CP="CAO PSA OUR"');
ob_start();
session_start();

Other things learned during MySpace development.

  • Everything works just fine in FireFox, IE7 is the only culprit :p
  • If you try to send any OpenSocial request through MySpace IFPC library in IE7 before the page is fully loaded, IE7 will give alert error saying Object Not Found. To fix this wait for page load and then make request.
  • request.AdjustHeight() will not work in IE7 if Symfony’s development (frontend controller) environment is enabled.
  • I’ve already forgot a lot of things that I learned, will try to remember them again and bookmark them.

Similar Posts

8 Responses to “Fixing IE7 dropping PHP Sessions”

B@D on February 11th, 2009 at 5:02 PM

IE7 is still way better ( as microsoft proclaims & somehow it is ) than its old and stinky as shit previous version IE6.
The new IE8 is even worse. I installed a beta few weeks ago and it changed my OS Language to some Alien code shit.

B@D on February 11th, 2009 at 5:03 PM

One More thing.

Any IE version is a total crap. IE should be forbidden. I hope it will just disappear some day. It just give headaches to any web developer.

B@D on February 11th, 2009 at 5:07 PM

http://davidwalsh.name/

A very good Blog for PHP/MySQL and All.

prøXima on February 12th, 2009 at 12:56 AM

There is also problem with safari and iframe, if Iframe src is on other domain than parent, it will not save session cookie by default.
the only way to fix this is to set Accept Cookie as Always in preferences >> security.

hisie on March 22nd, 2010 at 7:31 PM

Hello Kryptic.
I have seen your solution, but i don’t know where to put this code. At the begining of the layout it gives me a notice because the session have been started yet. I would like to put it out of the symfony core files (not in lib/vendor/symfony/storage, neither other place inside vendor) to made it symfony version independant. Can you help me with this issue?

Kryptic on March 23rd, 2010 at 2:24 PM

@hisie
Well in symfony, one solution is to disable Automatic Session start in app’s factories.yml file and then start it manually in preExecute function of your module’s actions.class.php after setting header code.

hisie on April 6th, 2010 at 7:04 PM

@Kryptic
Thank you very much. It still does not work, but i have reported the issue to symfony trac (#8422). I have changed what you said leaving factories.yml:
**
storage:
class: sfSessionStorage

param:
session_name: casaruraltenerife
auto_start: false
**
and in the actions of the modules (them all):
**
public function preExecute(){
header(‘P3P: CP=”CAO PSA OUR”‘);
ob_start();
session_start();
}
**

Kryptic on April 8th, 2010 at 1:05 AM

@hisie
I don’t think this is problem with Symfony. The problem is with IE.
Can you tell me your scenario, what you’re trying to do?

Leave a Reply