PHP Object Persistence

Hi fellas,

First, sorry for any typos, I’m from Brazil =]

I need to make my User class persist. Is it possible with PHP?

Thanks in advance.

@Gerep: It is indeed possible to persist - but the subject is so big that it may be more appropriate for you to do some research into the subject before asking the question. Answering your question from scratch may be a little too much for the scope of a forum post, and there are several threads that deal with this topic already.


I suggest you do some research in the following Google results, and then come back with more specific questions:

Gerep, PHP is usually stateless, which means each page requests is isolated from the others. The server doesn’t (normally) maintain objects in memory between request, they get rebuilt each time. So for a login system the user normally carries a session ID in a cookie which can then be used to access data to rebuild the object on each request.

What do you mean by “persist my user class” ?

Ok G.Schuster, but just be patient and do you really think I would waste time just wondering if it is possible without the need of help? I see you have experience with it but I DON’T, so don’t bother wasting your precious time answering “yes” trying to be useful ok? Thanks!

Anyone else can help with this issue? I need to persist my User class, I’ve found a thread here but it dates 2007 =/

Thanks in advance.


G.Schuster, have any link?

Sorry, but please be more precise with what you have and what you want to achieve.
Just asking if it is possible to do X with Y leaves too much space for imagination for all potential helpers. might be a good read.

Can’t you just map the users data stored in the session back to your user object every request?