RE: [PHP] php session not persisting
| From: | Johnson, Kirk | Date: | Tue, 03 Jun 2003 21:55:06 +0000 |
| Subject: | RE: [PHP] php session not persisting | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-150083@lists.php.net to get a copy of this message | ||
Set your error reporting to E_ALL, to see if anything else is going on.
Add this line right after session_start() in both files, to make sure the
session ID is getting passed correctly. The same ID should be displayed in
both files:
echo "ID = " . session_id() . "<BR>";
> -----Original Message-----
> From: Eric D. [mailto:ericd_@hotmail.com]
> Sent: Tuesday, June 03, 2003 3:01 PM
> To: php-general@lists.php.net
> Subject: Re: [PHP] php session not persisting
>
>
> Thanks Kirk! I have all of the conditions you set out met.
> And still doesn't
> work.
>
> I also added session__is_registered("sess_var") to check and
> it tells me
> that it's not registered.
>
> 1st script - page1.php:
>
> <?
>
> session_start();
> session_register("sess_var");
>
> $sess_var = "Hello world!";
>
> echo "The content of \$sess_var is $sess_var<br>"; //echos
> fine here
>
> ?>
> <a href = "page2.php">Next page</a>
>
>
> 2nd script - page2.php:
>
> <?
>
> session_start();
> if (session_is_registered("sess_var"))
> { echo "true<br><br>";}
> else
> {echo "false<br>";}
>
> echo "The content of \$sess_var is $sess_var<br>";
> //$sess_var NOT printed
> echo "sess_var = $_SESSION[sess_var]<br>";
>
> session_unregister("sess_var");
> ?>
>
>
> "Kirk Johnson" <kjohnson@zootweb.com> wrote in message
> news:B11731D518B5D61183C700A0C98BE0D902587138@chef...
> > > Thanks. I'm using PHP-4.3.1.
> > >
> > > The problem is not with $_SESSION. I used
> > > session_is_registered("sess_var");
> > > to check from the second script and cannot see the
> > > variable("sess_var"). Can
> > > anyone tell me why?
> >
> > Your code should work for register_globals "on". Check that:
> >
> > - php.ini is where it is supposed to be (/usr/local/lib/, I think).
> > - register_globals is really to set to on in php.ini.
> > - that cookies are enabled in your browser.
> > - you don't have an .htaccess file in your directory with
> register_globals
> > turned off in it.
> >
> > Kirk