Re: sessions... unexpected behavior

From: Date: Fri, 15 Dec 2000 17:29:18 +0000
Subject: Re: sessions... unexpected behavior
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-30545@lists.php.net to get a copy of this message
Richard, thanks for your reply. However, your proposal doesn't scratch my itch - I need sessions working correctly in an environment where register_globals is OFF. The manual doesn't mention you can't use sessions in such an env, and I don't believe this is intended behavior. At 02:22 15.12. 2000, Richard Lynch wrote the following: -------------------------------------------------------------- >$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 >> > > >-- >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 ------end of quote------ ____________________________________________________________ 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 ICQ: 2808 2505

« previous php.general (#30545) next »