php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #17441 session register
Submitted: 2002-05-26 16:40 UTC Modified: 2002-05-30 17:58 UTC
Votes:3
Avg. Score:5.0 ± 0.0
Reproduced:2 of 2 (100.0%)
Same Version:2 (100.0%)
Same OS:2 (100.0%)
From: jrg89 at hotmail dot com Assigned:
Status: Not a bug Package: Session related
PHP Version: 4.2.1 OS: windows
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: jrg89 at hotmail dot com
New email:
PHP Version: OS:

 

 [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. 

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-05-26 17:23 UTC] jrg89 at hotmail dot com
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>
 [2002-05-30 15:55 UTC] n dot ponsich at netcourrier dot com
Y have the same trouble with win XP and easyPHP 1.6 even if i upgarde
PHP to 4.2.1
 [2002-05-30 16:33 UTC] n dot ponsich at netcourrier dot com
mytrouble is resolved in the 4.2.2dev
 [2002-05-30 17:58 UTC] mfischer@php.net
From http://www.php.net/manual/en/function.session-register.php:

"For each name, session_register() registers the global variable with that name in the current session."

and further

"If you are using $HTTP_SESSION_VARS/$_SESSION, do not use session_register(), session_is_registered() and session_unregister()."

 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Nov 23 10:01:28 2024 UTC