Re: sessions... unexpected behavior
| From: | Richard Lynch | Date: | Fri, 15 Dec 2000 01:22:50 +0000 |
| Subject: | Re: sessions... unexpected behavior | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-30425@lists.php.net to get a copy of this message | ||
$HTTP_SESSION_VARS is probably only created after you come back to a second
page.
Just use $count everywhere you have $HTTP_SESSION_VARS, and it will work
fine.
----- Original Message -----
From: Cynic <cynic@mail.cz>
Newsgroups: php.general
Sent: Thursday, December 14, 2000 7:01 AM
Subject: [PHP] sessions... unexpected behavior
> I admit that although I am quite experienced PHP 4 user,
> sessions is a new ground for me. However, PHP 4 behavior
> exhibited in session handling functions isn't exactly
> what I'd expect...
> (tested with about two days old CVS snapshot)
>
> test.php source
> ===============
> 01 <?
> 02 error_reporting( E_ALL ) ;
> 03 session_name('testsession') ;
> 04 session_start() ;
> 05 $count = 0 ;
> 06 session_register( 'count' ) ;
> 07 $HTTP_SESSION_VARS['count']++ ;
> 08 echo session_is_registered('count') ? 'yes' : 'no' ;
> 09 echo $HTTP_SESSION_VARS['count'] ;
> 10 echo '<a href="/test2.php">test2.php</a>' ;
> 11 ?>
>
> test.php output
> ===============
> Warning: Undefined index: count in <snip>/test.php on line 7
> yes
> 1
> test2.php
>
> test2.php source
> ===============+
> 01 <?
> 02 error_reporting( E_ALL ) ;
> 03 session_name('testsession') ;
> 04 session_start() ;
> 05 session_unregister( 'count' ) ;
> 06 $HTTP_SESSION_VARS['count']++ ;
> 07 echo session_is_registered('count') ? 'yes' : 'no' ;
> 08 echo $HTTP_SESSION_VARS['count'] ;
> 09 echo '<a href="/test3.php">test3.php</a>' ;
> 10 ?>
>
> test2.php output
> ================
> no
> 2
> test3.php
>
> test3.php source
> ===============+
> 01 <?
> 02 error_reporting( E_ALL ) ;
> 03 session_name('testsession') ;
> 04 session_start() ;
> 05 $HTTP_SESSION_VARS['count']++ ;
> echo session_is_registered('count') ? 'yes' : 'no' ;
> echo '<a href="test.php">test.php</a>' ;
>
> test3.php output
> ================
> yes
> 3
> test.php
>
>
>
> Is this what it's supposed to do?
>
>
> ____________________________________________________________
> Cynic:
>
> A member of a group of ancient Greek philosophers who taught
> that virtue constitutes happiness and that self control is
> the essential part of virtue.
>
> cynic@mail.cz
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
> For additional commands, e-mail: php-general-help@lists.php.net
> To contact the list administrators, e-mail: php-list-admin@lists.php.net
>