I currently use sessions pretty heavy and I am re-coding my network site right now. 1 thing I have done is made a session class that has some simple methods for example here is how I would retrieve session data using my class.
$session = new Session();
// to set a session I would use this
echo $session->set('user_id');
// to view a session's data
echo $session->get('user_id');
Now this is basicly the same as setting a viewing a session variable the regular way except I run it through this session class, the purpose I have is to make it more flexible. I figure if all session data is ran through that class on a big site, then all I would have to do to change it’s source to use a cache or memcache or a database is to just change the session class file.
SO in reality I really don’t have much gain in using a class/methods for my session data at the moment but some day I might.
My question is, on a very high traffic site, would it be better to not be making the extra method/class call everytime I need to show sessions data?
You are using a pattern that is exemplified in several frameworks, one of which is the framework I personally use, Zend Framework.
The comments about optimization are correct, the performance hit of the session stuff you are doing is liable to be so minute that it wouldn’t matter in the end. There are numerous benefits that having a session class can provide for you, and the frameworks common use of a session object as opposed to simple session access via functions should show that clearly.
Regards,