On Wed, Sep 9, 2009 at 11:58 AM, Sumit Sharma <sumitp...@gmail.com> wrote:
> What I have done is declared one User class in a separate file and created
> its object there only. After this included this file in all other file which
> are using its object. So the object is creating only once and included in
> every other file only once. Now when I over write its variable it value get
> lost when I send the user in other file.
>
> The confusion is if I have created only one object of a class and used the
> same object through out the site how its value can get lost and I think this
> is a separate issue than setting $_SESSION variables.

This happens because your object is destroyed as soon as PHP finishes
serving the request. That's the way the web was designed. If you want
your object to persist from one request to another, YOU have to
persist it. There are lots of ways to do that. Storing your object in
a $_SESSION variable is one of those ways.

Andrew

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

Reply via email to