[thelist] php session variables problem

Maganizo Monawe mmonawe at gmail.com
Sat Jul 12 09:42:52 CDT 2008


I have two php pages. I am assigning values to session variables in
the first page so that I can use them in the second page.

The first time I open the browser and set the values, they are set
without problem. I am able to see the values in the second page.

When I go back to the first page to set the values to different
values, I get the same previous values. Even when I refresh the page.

I tried to unset the session variables after using them in the second
page. If I refresh the page the first time to see if the variables are
unset, I still get the same old values. If I refresh the page the
second time then I see that the values are gone.

I have been trying to work this out for some but have not succeeded.
What could this be?

This is my code:

At the top of the first page before the rest of the page including
headers I have the following code:

<?php

session_start();

session_register("stdate");
session_register("etdate");
session_register("ccode");

?>

within the page I have the following code where I am assigning the
variables above values:

if (isset($_POST['go']))
	{
	
	$sday = $_POST['sday'];
	$smonth = $_POST['smonth'];
	$syear = $_POST['syear'];
		
	$eday = $_POST['eday'];
	$emonth = $_POST['emonth'];
	$eyear = $_POST['eyear'];
		
	$sdate = mktime(0,0,0,$smonth,$sday,$syear);
	$edate = mktime(0,0,0,$emonth,$eday,$eyear);
		
	$ecode = $_POST['AType'];
	
	$_SESSION["stdate"] = $sdate;
	$_SESSION["etdate"] = $edate;
	$_SESSION["ccode"] = $ecode;
}


In the second page I have the following code to access the session variables:

At the top of the first page before the rest of the page including
headers I have the following code:

<?php

session_start();

$sttdate = $_SESSION['stdate'];
$ettdate = $_SESSION['etdate'];
$catcode = $_SESSION['ccode'];

?>


Is anything wrong with this setup that could cause the problem.

I am working on windows xp, and WAMP5 Version 1.7.3

Thanks,
Anthuni



More information about the thelist mailing list