jon parise // friday, august 22, 2014
PostgreSQL Session Handler for PHP
While at work in the summer of 2000, I encountered a need for some form of shared session storage for PHP. The obvious solution was to use a relational database as the common session cache. We were already using PostgreSQL for our other database needs, so it seemed logical to keep our software consistent.
With that in mind, however, MySQL may have been a better choice, due to it's good performance on simple read and update operations, but I was not interested in introducing another complex piece of software into the mix.
I wrote and tested this in a few hours one day. It appears to work quite well, but I have yet to test it under a heavy load.
A number of other folks have started using it, however, and I've received a lot of positive feedback, along with some helpful comments and patches. Keep them coming! They benefit everyone.
To use it, simply follow the instructions in the header comment and include the code in every page that uses PHP's session functions.
This code is released under a BSD-style license.
Copyright © 1997-2014 by
All rights reserved.
Last updated: February 26, 2008 02:33 EST
Valid XHTML 1.0 // Valid CSS