Re: Session Managment?

From: Date: Sat, 01 Jul 2000 16:37:25 +0000
Subject: Re: Session Managment?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-4269@lists.php.net to get a copy of this message
Hi Jay! On Fri, 30 Jun 2000, Paulson, Joseph V. Jay wrote: > I'm doing some research and learning PHP sessions and sessions for Java > Servlets. I was wondering if anyone had a prefrance to one over the other? > Does anyone have any pro's and con's for each? I really don't know what the > advantages and dissadvantages of each are and would really like some input > if anyone has any... Yeah, so far I preffer the Servlet model, since it's more OO based. For some time now I've been coding wrapper classes for PHP, namely HttpServletRequest/Response -> HttpRequest/Response, and now I am stuck at sessions. The bigest difference is that a servlet is initialized once (when the init() method is called) and lives until destroyed, whereas in PHP there is no equivalent for this. Your page is parsed and executed every time. Plus, a servlet can have multiple threads using the same session, and the objects bound to it. On the session support side both PHP and Servlets offer Cookie and URL rewriting support. Some concrete problems I faced in `emulating' the Servlet API were SessionBindingListener and SessionBindingEvent, cause you only have __sleep and __wakeup for serialization, but you have to code a way to tell to an object it was bound/unbound from a session. Also to portably test if the session is new (the isNew() method) you'll have to look in several places, and/or eventually read some config parameters before that. Then, I would really appreciate if somebody would explain how session_register() works, namely where does it look for those variables. I sow least "register_globals" affects its behaviour. In Java you have setAttribute('name', object), which is far more easy to use (to me:) To have a clearer view of the differences you should least have a look over the Servelt API (javax.servlet) and do yourself some simple examples with it, then compare it to PHP session. -- teodor

« previous php.general (#4269) next »