Page 1 of 1

Image Kills session in IE

Posted: Wed Aug 17, 2005 3:25 pm
by hawleyjr
Alright check this out. I was displaying an image dynamically by doing the following:

Code: Select all

<img src="<?php echo 'getimg.php?id=abc;?>" width="100" height="100">
Works fine... However, I had to do this five times so I first created five blank img tags:

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">
And then inserted my PHP one img at a time:

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">
and then...

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">
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...?

Code: Select all

//No good in IE:
<img src="" width="100" height="100">
I fixed my code and it works fine. However, I haven't heard of this happening.

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>
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...

Posted: Wed Aug 17, 2005 3:39 pm
by feyd
works, as expected in IE 6.0.2900.2180 SP2 and Firefox 1.0.6 for me.

Posted: Wed Aug 17, 2005 3:51 pm
by hawleyjr
With that said. I loaded the same page onto another server. Works fine in both IE and FF.

This has to be a server setting with IE not just IE...?

Any ideas?

Posted: Wed Aug 17, 2005 4:36 pm
by feyd
use curl to send a false (IE) user-agent to both servers asking for the headers as well as pages.. compare and contrast. :)