Re: Re: Class variable value lost

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, 2009-09-09 at 10:36 -0500, Shawn McKenzie wrote:
> Sumit Sharma wrote:
> > Hi,
> > 
> > I have developed a listing site which is totally class based. Now when it
> > authenticates a user login and set appropriate class variables to true and
> > set user info in user class variables, value of all the set variables are
> > lost when I forward the user to members page. When I check the the value on
> > other page it is set to the default value of the class. Please help.
> > 
> > 
> > Regard,
> >    Sumit
> > 
> 
> You needs to pass the object to the next page.  Look into sessions.
> 
> -- 
> Thanks!
> -Shawn
> http://www.spidean.com
> 
The object only exists for that instance of the script, so when the user
navigates to the next page, the object is freed up from the memory.
There are a couple of ways you could get round this:

      * don't navigate away from the page, and use AJAX calls to update
        parts of the page for the user (bad imho, as it relies on
        Javascript)
      * use sessions like Shawn recommended

If you use sessions, you can store the objects themselves as variables
into the session. You should be careful with this, as you may not want
too many sessions open with large objects in them as, depending on your
server setup, sessions could last quite a while, and there may also be a
limit on the amount of memory reserved for sessions.

Thanks,
Ash
http://www.ashleysheridan.co.uk




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux