Page 1 of 1

Session variables

Posted: Wed Feb 25, 2004 2:59 pm
by mikeb
Hi,

I'm trying to get session variables working. I have a local (development) version of my site on win2k/apache/php4x/mysql. The remote site uses Linux/apache/php4x/mysql. Ok, I am going through a tutorial from Devshed which supplies this code (which I'm using to test my setup):

<?
session_start();
session_register("SESSION");

if (! isset($SESSION)) {
$SESSION["count"] = 0;
echo "<li>Counter initialized, please reload this page to see it increment";
} else {
echo "<li>Waking up session $PHPSESSID";
$SESSION["count"]++;
}
echo "<li>The counter is now $SESSION[count] ";
?>

Simple enough piece of code! It adds one to the variable on refreshing the page and displays the new value each time. Works fine remotely, but not locally. No error message locally either. Keeps printing the value of $SESSION[count] as zero. Don't get the 'waking up session...' echoing either. I did a side by side comparison with phpinfo() on both servers. Both match in all the [session] settings. Any idea what could be wrong locally?

Posted: Wed Feb 25, 2004 3:03 pm
by d3ad1ysp0rk
- Put your code in

Code: Select all

 tags for easier reading
- try this:
[syntax=php]<? 
session_start(); 

if (! isset($_SESSION)) { 
$_SESSION['count'] = 0; 
echo "<li>Counter initialized, please reload this page to see it increment";
} 
else { 
echo "<li>Waking up session $PHPSESSID"; 
$_SESSION['count']++; 
} 
echo "<li>The counter is now $_SESSION['count'] "; 
?>[/syntax]

Posted: Wed Feb 25, 2004 3:24 pm
by mikeb
Thank you! I'll give that a try. I'm presuming a dollar underscore for the third line of php?

thanks,

Mike

Posted: Wed Feb 25, 2004 3:54 pm
by d3ad1ysp0rk
yup, sorry i forgot that one :P

*edited*