RE: [PHP] session_register()

From: Date: Thu, 03 May 2001 06:21:02 +0000
Subject: RE: [PHP] session_register()
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-51220@lists.php.net to get a copy of this message
Jennifer, I could be wrong but this is what I think you have; When the session_register is executed the session contents are partially updated. Your first test actually executed the session_register that posted the variable with 0 string length, because the variable had not yet been initialized (the bad return is the only indication of this). Your test that the variable is registered would seem to suggest this. You then changed the variable value and failed to register this new value. The second page found the only value you registered (the uninitialized variable with zero length) and displayed that. You can identify what actually happened by viewing the session file contents after your two pages are displayed. hope this helps, Warren Vail -----Original Message----- From: Jennifer [mailto:toxlists@canada.com] Sent: Wednesday, May 02, 2001 10:55 PM To: php-general@lists.php.net Subject: Re: [PHP] session_register() "Johnson, Kirk" wrote: > > > -----Original Message----- > > From: Jennifer [mailto:toxlists@canada.com] > > Do you need to register a variable with the session before you > > assign it a value? > > Not in my experience. > > > session_register should return true if the variable was > > successfully registered? > > It returns "1". > > > The variable name and it's value should be written to the file > > with the same name as session_id()? > > Yes, here's a sample from a session file: superUser|s:3:"Yes"; > Here's a sample session filename: sess_01bc2e24aa5291300887948f0af74899 This is all what I thought, but I am still having problems and I don't have a clue what I am missing. Here's an example that I have been paying with for testing. page1.php contains <?php session_start(); echo "session id is ".session_id()."<br>\n"; if (session_register("testing")) { echo "session_register worked.<br>\n"; } else { echo "session_register did not work<br>\n"; } if (session_is_registered("testing")) { echo "testing is a registered variable<br>\n"; } else { echo "testing is not a registered variable<br>\n"; } $testing = "Let's see if this works."; ?> <a href="page2.php?<?=SID?>">Go to next page.</a> The output of the above page, gives me session id is e35c2893382e28a14fa0455302edb06e session_register did not work testing is a registered variable Go to next page. and page2.php contains <?php session_start(); echo "session id is ".session_id()."<br>\n"; echo "Testing: $testing<br>\n"; ?> The output of page2 gives me session id is e35c2893382e28a14fa0455302edb06e Testing: I am totally confused. First off, why isn't it registering the variable? There is a file named e35c2893382e28a14fa0455302edb06e in my /tmp directory, but it is empty. Second, if it isn't registering the variable then why is session_is_registered("testing") returning true? Jennifer -- 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

« previous php.general (#51220) next »