Board index   FAQ   Search  
Register  Login
Board index PHP PHP Installation

sessions dont work

Forum for you who has PHP installation issues

Moderators: macek, egami, gesf

sessions dont work

Postby gadio » Wed Mar 10, 2004 1:32 pm

Hi
I try to run this simple piece of code on my localhost and it doesn't work.
It's supposed to increment a session variable if it is set.
It works fine on my web server.
I have wXP.
<?
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] ";
?>

I tried to modify php.in with no results.
Any help? thanks
gadio
New php-forum User
New php-forum User
 
Posts: 2
Joined: Wed Mar 10, 2004 1:28 pm

Postby swirlee » Wed Mar 10, 2004 1:41 pm

Skip the session_register('SESSION') and instead use the predefined superglobal $_SESSION.
User avatar
swirlee
Moderator
Moderator
 
Posts: 2272
Joined: Sat Jul 05, 2003 1:18 pm
Location: A bunk in the back

Postby gadio » Wed Mar 10, 2004 2:07 pm

thank you very much swirlee! It worked!

<?
session_start();
if (! isset($_SESSION['count'])) {
$_SESSION['count'] = 0;
} else {
$_SESSION['count']++;
}
echo $_SESSION['count'];
?>
gadio
New php-forum User
New php-forum User
 
Posts: 2
Joined: Wed Mar 10, 2004 1:28 pm


Return to PHP Installation

Who is online

Users browsing this forum: No registered users and 1 guest

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.

cron