PHP: session seems to be lost after header redirect only on IE
I can't find a good answer for this anywhere. I have a login page, and after a good login it redirects to main page. In FF, and chrome - works perfect. On IE it doesn't work. I keep losing the session when I get to the main page.
I have checked the following: - session_start at top - no blanks or anything befoer header redirect - one line before the redirect, IE knows the session user id, but after the redirect, just one line after the session start, it loses the session user id - I've checked it also on other computer - same results
What is wrong w开发者_如何学运维ith IE? or what could be wrong with my script ? Thanks
- Set PHP's
error_reporting
to-1
; reproduce error; check logs - Check IE's privacy settings--
$_SESSION
relies on either a cookie or URL-based session identifier. It seems as though it's having trouble saving the cookie - Is there anything you're doing to the response that is not standard (eg modifying headers)
- Can you build an extremely simple version of this code and test it using nothing but the bare essentials (narrow down the problem to a specific bit of code)
[Edit]
- Make sure you aren't calling
session_start()
twice ;)
Ok,
Problem solved. I can't find the logic behind this solution, but although I had session_start() at the top of the page, I added another session_start() just before writing the session vars.
精彩评论