Re: Session hell: register_globals off
| From: | Randall Perry | Date: | Sun, 04 Apr 2004 18:51:10 +0000 |
| Subject: | Re: Session hell: register_globals off | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-182295@lists.php.net to get a copy of this message | ||
Solved my main problem. I was assuming that variables registered with
$_SESSION were passed by reference. Apparently they're passed by value.
I moved the line '$_SESSION['order'] = $order;' from the top of the page 1
php code (before any properties for the order object are set), to the end of
the php code -- now everything's getting passed to page 2 ok.
This is an important point that should probably be in the docs section on
sessions.
When I coded using session_register() with register_globals on registering
the variable before making changes to it worked.
The '[error] PHP Notice: Undefined variable: _SESSION' happened, I think,
because there were no session variables to pass so PHP killed the session.
> Had a previous thread on this issue. Started working on it again and am
> running into new bugs, so thought I'd start a new thread.
>
> Read thoroughly through session examples in docs and here's how I tried to
> pass an object from one page to another:
>
>
> page 1
> ______
>
> // include class definition file
> include_once "order_classes.php";
> // start session
> session_start();
> // create instance of class Order
> $order = New Order();
> // assign class instance to $SESSION[]
> $_SESSION['order'] = $order;
>
> page 2
> ______
>
> // include class definition file
> include_once "order_classes.php";
> // start session
> session_start();
> // assign $_SESSION['order'] object to variable
> $order = $_SESSION['order'];
>
>
> I'm getting the following error when page 2 loads:
> [error] PHP Notice: Undefined variable: _SESSION
>
> Any ideas?
>
>
>
>
>
> Pertinent PHP vars:
> ___________________
>
> Darwin systame.cniweb.net 7.2.0 Darwin Kernel Version 7.2.0: Thu Dec 11
> 16:20:23 PST 2003; root:xnu/xnu-517.3.7.obj~1/RELEASE_PPC Power Macintosh
>
> Build Date Apr 2 2004 12:58:17
>
> Configure Command './configure' '--with-apxs=/usr/sbin/apxs'
> '--with-pgsql'
> '--with-xml' '--with-openssl=/usr/local/ssl' '--with-pear'
> '--with-curl=/usr/lib'
>
> Apache/1.3.29 (Darwin) DAV/1.0.3 mod_perl/1.29 PHP/4.3.5 mod_jk/1.2.4
> mod_ssl/2.8.16 OpenSSL/0.9.7c
>
> register_globals Off Off
>
--
Randall Perry
sysTame
Xserve Web Hosting/Co-location
Website Development/Promotion
Mac Consulting/Sales
http://www.systame.com/