Hi
I am pulling my hair out over this problem, and am getting to the stage where I'm gonna scream.
All these pages work perfectly on IE6, Firefox, Netscape etc, but I have come across a problem when testing them on IE7.
Here's the problem:
I have a web based system where a user logs into the site. Upon signing in, a number of PHP $_SESSION variables get populated with data, so that the subsequent pages know that he is allowed to visit them, and who he is.
One of these variables is:
$_SESSION['username']
At the top of all subsequent pages, the php script reads:
< php
session_start();
if (!isset($_SESSION['username'])) {
header("Location:unauthorised.php");
exit;
}
>
This effectively checks to see if the user is logged in, and if not, sends them to the "unauthorised" page.
This check works fine.
However, on one of these subsequent pages, I have a link that opens a new window with some information, using the standard <a tag. This is the link :
<a href="new_page.php" target="_blank">Click here</a>
Now, this "new_page.php" also has the script that checks to see if the user logs in.
This new page is displayed fine.
HOWEVER, and this is my problem........
When I close this new window (using IE7 - it works fine in other browsers), and am left with the original page with the link on it, my session data seems to disappear. If I click on refresh, I'm taken to my "unauthorised" page.
WHY IS THIS HAPPENING IN IE7
So, to recap.........
1) User logs in and session variable stores $_SESSION['username']
2) User goes to new page (page checks to see if logged in - which he is)
3) User click on link on this page which opens new window (using target="_blank").
4) This new window displays fine (page checks to see if logged in - which he is)
5) Close this new window, leaving the original page with the link on
6) Refresh the page (or click the link again) and all session data is lost - sent to unauthorised page
This is only a problem in IE7.
Can someone please suggest a workaround for this issue. I'm almost positive it's a IE7 fault, but am amazed that there aren't loads of people with this issue posting on forums.
It seems IE7 doesn't handle session data correctly.
Many many thanks for any help you can give