I did a search and didn't find much about this so I'd like to ask...
As I try to implement more OO code into my everyday life. I am struggling to find the benefits of creating a session class...
Here is how I normally use sessions...(small snippit of course)
My main header file starts the session so it is available on all pages that include the header file...
As the user successfully logs in, I create a session for them that would include your basic needs, info taken from the DB...
(SQL query and results)
$_SESSION['username'] = $rows["username"];
$_SESSION['userid'] = $rows["userid"]
So that's about it. As I need to access the username, I just simply access the superglobal array throughout the site...
echo "Username: " . $_SESSION['username'];
I read a good OLD post just now from Xenon about not trying to make everything you do in OO....and I do think that makes sense too...
So is making a session class overkill? Are there any benefits to it especially since it's a superglobal array that I can access anywhere on the site by just calling: $_SESSION...
Am I not seeing the bigger picture because I'm using it in such a basic way?
Ok so here's an example....say I want to access a session variable the "procedural way"..
The OOP way:
It almost seems like going out of your way to use OO for session data?
|All times are GMT. The time now is 07:46 AM.|
Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0