News Feed
Sections




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

PHPMaster.com:
Writing Custom Session Handlers
December 29, 2011 @ 09:41:25

On PHPMaster.com today there's a new post showing you how to write custom session handlers - in their case, a database-based option that can span across multiple servers/services.

Sessions are a tool which helps the web programmer overcome the stateless nature of the internet. You can use them to build shopping carts, monitor visits to a website, and even track how a user navigates through your application. PHP's default session handling behavior can provide all you need in most cases, but there may be times when you want to expand the functionality and store session data differently. This article will show you how the default functionality works and then goes on to show you how override it to provide a custom solution.

They introduce how sessions are stored normally (based on the save path) and what the serialized contents of it would look like. They show you how to take this, normally stored on the local file system, and change it to be written to a "session" table in a MySQL database (via PDO). It includes reading, writing, updating and some garbage collection to clean out old values from the table.

0 comments voice your opinion now!
custom session handler tutorial mysql database pdo


blog comments powered by Disqus

Similar Posts

Sean Coates' Blog: Deploy on push (from GitHub)

NetTuts.com: A BDD Workflow With Behat and Phpspec

Wojciech Sznapka's Blog: Power of PHP streams decompress gz archives on the fly from remote server

NETTUTS.com: How To Build a Widget to Display your Buzzing

NETTUTS.com: Deciphering Magic Methods in PHP


Community Events

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


conference application php7 community language opinion example library introduction release series laravel podcast interview configure voicesoftheelephpant symfony2 framework api performance

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