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?
Session variables
Moderator: General Moderators
-
d3ad1ysp0rk
- Forum Donator
- Posts: 1661
- Joined: Mon Oct 20, 2003 8:31 pm
- Location: Maine, USA
- 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]
Last edited by d3ad1ysp0rk on Wed Feb 25, 2004 3:54 pm, edited 1 time in total.
-
d3ad1ysp0rk
- Forum Donator
- Posts: 1661
- Joined: Mon Oct 20, 2003 8:31 pm
- Location: Maine, USA