Re: [phplib] Object not found From: Steve Edberg (sbedberg <email protected>)
Date: 01/22/01

At 4:07 PM +0100 1/22/01, A.C.N.S. Information and News wrote:
>Sorry for the error but the class I was talking about is the Session class
>in the session.inc file. There is no page_open class. page_open is the
>function that calls the session class from the included session.inc.
>
>Again sorry for the confusion. hehe. I'm still a bit confused myself.
>
>Chuck
>
>----- Original Message -----
>From: "A.C.N.S. Information and News" <infomail <email protected>>
>To: "Mauricio Cuenca" <mcuenca <email protected>>; "PHPLib List"
><phplib <email protected>>
>Sent: Monday, January 22, 2001 3:57 PM
>Subject: Re: [phplib] Object not found
>
>
>> I've run into the same problem.
>>
>> It is because of the page_open() command and all being built as classes.
>> Which basically boils down to: once you leave the code structure of the
>> page_open() command you no longer have access to that class that was
>> created.
>>
>> So, the following would work np.
>>
>> page_open(array("sess" => "cart_sess"));
>> if (!isset($SESSION)) { $SESSION=0; };
>> $sess->register("SESSION");
>> $sess->purl("store.php3?section=clothing&cat=1");
>>
>> but the following won't.
>>
> > page_open(array("sess" => "cart_sess"));
>> if (!isset($SESSION)) { $SESSION=0; };
>> $sess->register("SESSION");
>> function test($section, $cat){
>> $sess->purl("store.php3?section=clothing&cat=1");
>> };
> >
>> because the session is no longer able to see the original class. It's all
>a

Well, this should work in you globalize your $session object:

    page_open(array("sess" => "cart_sess"));
    if (!isset($SESSION)) { $SESSION=0; };
    $sess->register("SESSION");
    function test($section, $cat){
       global $sess;
       $sess->purl("store.php3?section=clothing&cat=1");
    };

Alternatively, you could pass it as a parameter:

    page_open(array("sess" => "cart_sess"));
    if (!isset($SESSION)) { $SESSION=0; };
    $sess->register("SESSION");
    function test($section, $cat, $sessionObj){
       $sessionObj->purl("store.php3?section=clothing&cat=1");
    };

- steve

-- 
+--- "They've got a cherry pie there, that'll kill ya" ------------------+
| Steve Edberg                           University of California, Davis |
| sbedberg <email protected>                               Computer Consultant |
| http://aesric.ucdavis.edu/                  http://pgfsun.ucdavis.edu/ |
+-------------------------------------- FBI Special Agent Dale Cooper ---+

--------------------------------------------------------------------- To unsubscribe, e-mail: phplib-unsubscribe <email protected> For additional commands, e-mail: phplib-help <email protected>