Image Kills session in IE
Posted: Wed Aug 17, 2005 3:25 pm
Alright check this out. I was displaying an image dynamically by doing the following:
Works fine... However, I had to do this five times so I first created five blank img tags:
And then inserted my PHP one img at a time:
and then...
etc....
I was testing the image each time to make sure it worked. The images showed up in FF just fine. They also showed up in IE just fine...
However, this is where I got stumped. When I refreshed the page in IE my session died and it took me back to my login page.
After investigating I found that in IE if you insert an image with a blank src="" for whatever reason your session variables die...?
I fixed my code and it works fine. However, I haven't heard of this happening.
Here is example code:
In FF after the first refresh it shows "Session is Set" and a blank image. In IE after the refresh it still shows "Session is not set"
Give it a try...
Code: Select all
<img src="<?php echo 'getimg.php?id=abc;?>" width="100" height="100">Code: Select all
<img src="" width="100" height="100">
<img src="" width="100" height="100">
<img src="" width="100" height="100">
<img src="" width="100" height="100">
<img src="" width="100" height="100">Code: Select all
<img src="<?php echo 'getimg.php?id=abc;?>" width="100" height="100">
<img src="" width="100" height="100">
<img src="" width="100" height="100">
<img src="" width="100" height="100">
<img src="" width="100" height="100">Code: Select all
<img src="<?php echo 'getimg.php?id=abc;?>" width="100" height="100">
<img src="<?php echo 'getimg.php?id=def;?>" width="100" height="100">
<img src="" width="100" height="100">
<img src="" width="100" height="100">
<img src="" width="100" height="100">I was testing the image each time to make sure it worked. The images showed up in FF just fine. They also showed up in IE just fine...
However, this is where I got stumped. When I refreshed the page in IE my session died and it took me back to my login page.
After investigating I found that in IE if you insert an image with a blank src="" for whatever reason your session variables die...?
Code: Select all
//No good in IE:
<img src="" width="100" height="100">Here is example code:
Code: Select all
<?php
session_start();
if(isset($_SESSION['MY_SESSION'])){
echo 'Session is Set';
}else{
echo 'Session is not set';
//SET SESSION
$_SESSION['MY_SESSION'] = 'Hello World';
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Untitled Document</title>
</head>
<body>
<img src="" width="100" height="100">
</body>
</html>Give it a try...