Liberica’s profile

Latest Comments


You can implement PHP Sessions in a database without writing any code, and it will automatically work for all of your websites on a server.

See here for the full article:

In summary, PHP has built in support for session handling using SQLite, and all you need to do is to change the php.ini settings.

session.save_handler = sqlite
session.save_path = /path/to/phpsession.sdb

To check if you have sqlite configured as a registered save handler in PHP just run the following at the command line:

php -i | grep "Registered save"

If you get back something like this, with sqlite in there:

Registered save handlers => files user sqlite

you are good to go with just the php.ini change, if not, you need to install sqlite (just yum install php-sqlite if you are on CentOS)

Using MySQL as per your article, you could have made the table a MEMORY table so that the sessions are stored in memory instead of disk, which would also improve performance. Similarly, there is a registered save handler for PHP called mm which does much the same thing.

Posted in Storing Sessions in a Database.

Thu, 07 Jun 2012 at 04:50:47 GMT


  • Twitter: @liberica
  • Joined: June 2012
  • Comments: 1