session variables

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Zmodem
Forum Commoner
Posts: 84
Joined: Thu Apr 18, 2002 3:59 pm

session variables

Post by Zmodem »

Code: Select all

<?php
session_start();
if (!isset($_SESSION&#1111;'count']))
&#123;
	$_SESSION&#1111;'count'] = 0;
&#125;
else
&#123;
	$_SESSION&#1111;'count']++;
&#125;

echo $_SESSION&#1111;'count'];
?>
The above code was copied and posted into a php document straight from the PHP manual. It does not work on my machine for some reason.

$count is always 0. 0 is always echoed.

I am currently running win2k, php 4.1, apache 1.3.24

I have also tried $HTTP_SESSION_VARS on PHP 4.0.6 and that still did not work.

It does however, work fine if I just use globals (session_register("count");) etc etc.

I can't figure this out. Its beyond me. Perhaps I've missed something simple. ANyone have any ideas for me?

Thanks guys
jason
Site Admin
Posts: 1767
Joined: Thu Apr 18, 2002 3:14 pm
Location: Montreal, CA
Contact:

Post by jason »

I dont' know, it works here: http://www.phpcomplete.com/test.php and this is my PHPInfo output: http://www.phpcomplete.com/phpinfo.php
Zmodem
Forum Commoner
Posts: 84
Joined: Thu Apr 18, 2002 3:59 pm

Post by Zmodem »

Hmmm, odd.

Without changing the script, I upgraded from PHP 4.1.0 to 4.1.2. Still didn't work.

Then I upgraded to 4.2.0 and voila! works great!

Not sure what to think about that. I've never been one to scream "BUG!!"..... but.....
fatalcure
Forum Contributor
Posts: 141
Joined: Thu Jul 04, 2002 12:57 pm
Contact:

Post by fatalcure »

hum, how long do session variables last anyway?
User avatar
RandomEngy
Forum Contributor
Posts: 173
Joined: Wed Jun 26, 2002 3:24 pm
Contact:

Post by RandomEngy »

I think until you close the browser window or the session is destroyed or the variables are manually unset.
fatalcure
Forum Contributor
Posts: 141
Joined: Thu Jul 04, 2002 12:57 pm
Contact:

Post by fatalcure »

well yea, i thought it was till you closed the browser, but going to Jason's test scipt: http://www.phpcomplete.com/test.php , it seems to still be counting up from last time since i've closed my browser.

Just curious, i've never used sessions before.
Post Reply