Re: native vs. phplib sessions

From: Date: Mon, 07 Apr 2003 17:53:03 +0000
Subject: Re: native vs. phplib sessions
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-142729@lists.php.net to get a copy of this message
> John W. Holmes wrote: > > Whether your class operates on the $_SESSION array or your own array, > > what's the difference? I don't see a benefit here. > > I agree that that is the same. I would actually prefer a method that > operates on the data. For example, if you store the backgroud color of > your site in a session variable and you want to change it, you don't > have to include a file to make sure the function that sets it is > available. This is really just a preference. You still have to include your class file, though, right? That's irrelavant, though. Your class or function or whatever can just operate on $_SESSION instead of your own variable. No difference. > > > > http://www.php.net/manual/en/function.session-write-close.php > > > > I'll admit that before $_SESSION came along, sessions were a pain. All > > you do is call session_start() and then use $_SESSION like any other > > variable and it's contents will be available on any page with > > session_start(). How much easier can it be? > > Hehe. I even looked before I replied, I swear, apparently not very well > though. This doesn't account for a situation in which you have modified > a session and you don't want to save it. In that case, a call to session_readonly() would reset the session and not save it at the end (it can't be modified). > Anyway, I agree that the built > in sessions are excellent. I am not stating that one is better or easier > than the other, just that I think there are situations where you might > want to roll your own. Yeah, I guess so. The only benefit I see to rolling your own is compatibility across different versions of PHP (especially before there were sessions). ---John Holmes...

« previous php.general (#142729) next »