Jennifer, there are at least two of us totally confused. I did a copy and
paste of your code and got the expected results:
session id is afb1f9e27afc752f7d9e96e096ca2209
session_register worked.
testing is a registered variable
with the contents of /tmp/sess_afb1f9e27afc752f7d9e96e096ca2209 being:
testing|s:24:"Let's see if this works.";
I then tried your code with register_globals = off. Interestingly, I got
"session_register worked" even though $testing was not registered (it can't
be registered with register_globals off).
I see nothing wrong with your code, so... some thoughts:
1. What browser are you using? I, and others, have seen erratic results with
sessions using Netscape 4.x. If this is your browser, try your code with
another browser, if possible.
2. This is a longshot, but who is PHP running as? By default, it is nobody.
In any case, check that whomever PHP is running as has write permission to
/tmp.
3. I cannot think of any other configuration settings in php.ini that might
be the trouble, since turning register_globals off does not reproduce your
results.
I am stumped.
Kirk
> -----Original Message-----
> From: Jennifer [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, May 02, 2001 11:55 PM
> To: [EMAIL PROTECTED]
> Subject: Re: [PHP] session_register()
>
>
> "Johnson, Kirk" wrote:
> >
> > > -----Original Message-----
> > > From: Jennifer [mailto:[EMAIL PROTECTED]]
> > > 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: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail:
> [EMAIL PROTECTED]
>
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]