05-04-2009, 06:54 PM
|
#1 (permalink)
|
|
The Gregarious
Join Date: Feb 2009
Location: New York
Posts: 645
Thanks: 64
|
Session class....
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...
session_start();
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"]
etc etc....
So that's about it. As I need to access the username, I just simply access the superglobal array throughout the site...
ex:
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?
Thanks!
|
|
|
|