SitePoint Zealot
Passing Objects In Sessions
Is this considered o.k to do?
I have a user object, created when a user has been verified and logs in. I need access to the functions to get data on the user from the database.
For example, I have an edit details page, which needs to load all the information into inputs.
Also instead of creating lots of session indexes I could also just use $_SESSION['user']->getUserID(); and stuff.
Any info on this appreciated.
¬.¬ shoooo...
Yes you can do that...
Easy no? $_SESSION['user'] = new User();
Logic without the fatal effects.
All code snippets are licensed under WTFPL .
The $_SESSION array can contain objects. Note that the object must be defined prior to session_start() so that the object can be properly reconstructed. You might also want to look at the __sleep() and __wakeup() special functions.
mikem
Posting Permissions
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
Forum Rules
Bookmarks