News Feed
Sections




News Archive
Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

DevShed:
Custom Session Management Using PHP and MySQL
May 11, 2011 @ 11:35:51

DevShed has a recent post looking at a handy feature PHP includes to let you be a bit more flexible with your session handling - the custom handlers that can be used for fun things like MySQL session handling.

Now the default PHP session management functions work just fine for most uses, and there is no reason to create a custom session handler if all you have is one server with a moderate amount of traffic and session use. However, remember that session data is stored locally on your server's hard drive. If you have more than one web server, obviously you will need to figure out another way to manage sessions so that the user's session can be restored regardless of which web server they hit. This is where PHP's session_set_save_handler() comes in handy.

The session_set_save_handler method allows you to define this custom handler and, in their example, push the session information (contents, modify date, ID) into a MySQL table for reading. They also mention some of the issues that might come up with this sort of handling including performance problems and incompatibility with any other language/tools that might need access to the session information.

0 comments voice your opinion now!
session management mysql tutorial custom


blog comments powered by Disqus

Similar Posts

NetTuts.com: So You Want to Accept Credit Cards Online?

DevShed: The preg_replace_callback() function in PHP

DevShed: Tracking Website Statistics with PHP

ParanoidFerret.com: Using Flex, PHP, and JSON to Modify a MySQL Database

James Morris' Blog: A Symfony2 Console Command and the Foursquare API Venuehistory


Community Events

Don't see your event here?
Let us know!


version community framework performance composer application voicesoftheelephpant interview podcast api laravel release opinion library symfony2 example php7 introduction series testing

All content copyright, 2015 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework