|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2002-05-26 16:40 UTC] jrg89 at hotmail dot com
I've been scratching my head over this for sometime now.
I'm sure I'm doing something wrong and hope someone can help. The problem is simple:
<?php
session_start();
if (isset($HTTP_SESSION_VARS['count']))
{
$HTTP_SESSION_VARS['count']++;
}
else
{
print "NOT registered:";
$HTTP_SESSION_VARS['count']=0;
}
?>
Hello visitor, you have seen this page <?php echo $HTTP_SESSION_VARS['count'] ?> times.<p>
To continue, <A HREF="http://localhost/jobs4us/main.php?<?php echo SID?>">click here</A>
-- The above code is available on the php site.
Problem:every time I reload the above page, or link to it from another page, $HTTP_SESSION_VARS['count'] always shows 0. Why? I can see the session is saved in my temp file (size 1K), but when i reload the page, why does the code 'think' that the session is not registered? Of course, I tried session_is registered("count") but to no avail. Any help would be appreciated.
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Nov 29 08:00:01 2025 UTC |
oops - left out session_register("count"); so the code looks like this: <?php session_start(); if (isset($HTTP_SESSION_VARS['count'])) { $HTTP_SESSION_VARS['count']++; } else { print "NOT registered session:"; session_register("count"); $HTTP_SESSION_VARS['count']=0; } ?> Hello visitor, you have seen this page <?php echo $HTTP_SESSION_VARS['count'] ?> times.<p> To continue, <A HREF="http://localhost/index.php?<?php echo SID?>">click here</A>