Page 1 of 1

SESSION ID lots when reloading page in IE.

Posted: Wed May 11, 2005 11:41 am
by trogledyte
Hi,

I have an serious issue with the SID, after page reload it's gone in IE.
With Firefox it works well, and on some of my servers with correct php.ini
files it works in IE too. But on the main server that I rent and have
all my pages on. It doesn't work with IE, no matter what I try.
Please check through this brief code and tell me what I'm doing wrong...

This is in file index.php:

Code: Select all

<?
   session_start();
   header(&quote;Cache-control: private&quote;); 
   
   $flashsite = isset($_GETї'flashsite'])?$_GETї'flashsite']: &quote;&quote;;
	
	if($flashsite==1) {
		$flashsite=5;
		$_SESSIONї'runalong'] = 666;
	}

   include('nyheter.php');

   $outputta = $_SESSIONї'runalong'];
   echo &quote; $outputta&quote;;

?>
This is in file nyheter.php:

Code: Select all

bla bla bla bla bla
bla bla bla bla bla
bla bla bla bla bla

<?
if ($flashsite==0) {
echo &quote;TRYCK <a href='index.php?flashsite=1'>.: HÄR :.</a>&quote;;
}
?>

<A HREF='index2.php?<?=SID?>'>THIS WORKS ON SOME PHP SERVERS</A>


Hope you can enlighten me in this! :lol:

d11wtq | Please read the sticky about posting code in the forums :-D

Posted: Wed May 11, 2005 11:53 am
by Chris Corbyn
How do you know it doesn't work? The value of SID will disappear after a page refresh or a move between pages. This is normal. The session id is generated at the start of the session and it is then stored so doesn't need to be displayed to the user.

Hope that helps ;-)

Posted: Wed May 11, 2005 12:18 pm
by trogledyte
Well it's not exactly the display issue of the SID.
It's rather that the SESSION variables get lost in the process.

Look at this:

IN cp.php

Code: Select all

<?
session_start();
header(&quote;Cache-control: private&quote;); 

$flashsite = isset($_GETї'flashsite'])?$_GETї'flashsite']: &quote;&quote;;

if($flashsite==1) {
$flashsite=5;
$_SESSIONї'runalong'] = 666;
}

include('cp2.php');

$outputta = $_SESSIONї'runalong'];
echo &quote;<br><br>Variabel: $outputta&quote;;

?>
IN cp2.php

Code: Select all

<?
if ($flashsite==0) {
echo &quote;PRESS <a href='cp.php?flashsite=1'>.: HERE :.</a> TO SET SESSION VARIABLE TO 666.&quote;;
}
?>
<br><br>
<A HREF='cp.php'>This doesn't pass on the Variable</A>
<br><br>
<A HREF='cp.php?<?=SID?>'>Passes on the variable when refreshed</A>
You can try the code out at my server http://www.morningdewmedia.com/cp.php


IF you press "Passes on variable" the SESSION variables are still available.
But in other case they are gone.
This works on my own webserver, but not on the other webserver which I am going to use the page.

Do you have a cluse why the session variable is gone on the other server I try?

I appreciate your fast reply!!! THANKS!

Posted: Wed May 11, 2005 12:39 pm
by Chris Corbyn
CAN YOU PLEASE READ THE RULES ON POSTING CODE USING

Code: Select all

TAGS.

You need to use session_start(); on the other page too in order to pick up the session id.

Any page which uses sessions should have this at the top...

Posted: Wed May 11, 2005 1:33 pm
by trogledyte
Well that's not the isse.
It's very strange because if I use this line in the second page cp2.php

Code: Select all

<A HREF='cp.php?page=another_page.php&<?=SID?>'>click here</A>
It will show the Session ID in the bottom of the window and will also refresh the page with the Session Variables intact.


BUT BUT BUT
If I use the same line within the first page cp.php

Code: Select all

<A HREF='cp.php?page=another_page.php&<?=SID?>'>click here</A>

The only workaround I have manage to do is to put the link in another file and include it to the cp.php file....hahaha but that can't really be the best solution. At least it writes out the SID number and keeps the variables intact.