Re: passing object variable from page to page. Please disregard the previous!
| From: | _lallous | Date: | Thu, 04 Oct 2001 07:08:45 +0000 |
| Subject: | Re: passing object variable from page to page. Please disregard the previous! | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-69891@lists.php.net to get a copy of this message | ||
you can always pass objects if you serialize them in the first page and then
unserialize them back in the 2nd page.
check serialize()
"Ming-Chieh Lee" <ming@thesmartport.com> wrote in message
news:20011003180022.21545.qmail@pb1.pair.com...
> Hello,
>
> > I have a question on how to pass object variable from page to page. Here
> is
>
> > something that I found, but it doesn't work. I would greatly appreciate
if
>
> > someone can help:
>
> > 1. does it matter if I include first, then so session_start()?
>
> >
>
> >
>
> > file1.php
>
> > <?
>
> > include ('class.myclass.php');
>
> > session_start();
>
> > $myvar = new MyClass;
>
> >
>
> > $myvar->who = "me";
>
> > // this is where my doubt reside !!!
>
> > session_register ('myvar'); // like this ?
>
> >
>
> > // don't need to register stuff in the class, it's already there.
>
> > // session_register ('who'); ?>
>
> > _____________________________________________
>
> > file2.php
>
> >session_start();
>
> > include ('class.myclass.php');
>
> > // using an "&" you won't make a copy and you
>
> > // can work directly on the session var
>
> > $myvar = &$HTTP_SESSION_VARS['myvar'];
>
> >
>
> > // should print "object"
>
> > echo "<br>" . gettype($myvar);
>
> >
>
> > // use the object, "who" is not a session var
>
> > echo "Session Var : " .$myvar->who. "<BR>";
>
> >
>
> > //echo "Session Var : " .$HTTP_SESSION_VARS['myvar']['who']
> > . "<BR>";
>
> > //echo "Session Var : " .$HTTP_SESSION_VARS['myvar->who'] .
> > "<BR>";
>
> > ?>
>
>
>