Originally posted by farberama
I tried your suggestion using $_SESSION and it still did not work. How do you go about managing your own sessions?
Did you try using $HTTP_SESSION_VARS? I would also give that a shot, or even $GLOBALS[HTTP_SESSION_VARS].
Building your own: It takes a bit of thought and work to set up, but might end up with a more scalable and efficient solution than using native sessions.
One method is to borrow somebody elses solution. Native sessions borrowed a lot of its methodologies from PHP_LIB which was a popular package that many used for this purpose before PHP introduced $_SESSIONs.
http://homepage.mac.com/ghorwood/php_lib_login/
To build one from the ground up, you try to decide whether to go with a database or file based system then after you decide to go with a database driven system you build a session table in your database to track the various variables you wish to keep track of.
When a user visits or logs into your site, you check if they have a cookie or session ID in the URL they arrived with. If not, you issue one to them and plant a cookie. If they do not accept the cookie every local link they have will have a really long URL and every form will have an extra hidden POST input. $_SESSIONs do this for you right now, but building your own you will need to do it in your code.
Every time they visit a page, you will update the database with the latest timestamp, as opposed to updating a file which $SESSIONs have been doing transparently. If they need to be logged in you can have columns in your table to track their access level or whatever, just as $SESSIONs give you the option of registering variables. Except now you are building your own register() function, or my preference, the OOP aproach $session->register()
If security is an issue, you would also put fields in your session table to record IP, forwarded IP, and browser used to validate against. It is fun!