Publish Date:31-08-2007
Archive Date:01-01-2020

mSess PHP Class

XmSess was created due to an oddity in PHP5 that caused unreliable sessions. While not exhaustively proven, there was some evidence that the internal serializer/deserializer in PHP was having problems with certain types of data, especially when larger amounts of data were packed into the $_SESSION super-global.

The net effect was mysterious, silent truncations in session data that were "inexplicable". Manual serialization efforts frequently returned errors on particular byte ranges.

While we could have modified the php.ini settings to make it use the built-in WDDX serializer to address this, we wanted to take the opportunuty to develop a MySQL backend for use in projects that needed to work on shared hosts, with privacy issues due to session data being stored in plain text files in globally accessible temp folders.

The end result is mSess, featuring:

  • MySQL as a backend for storing session data
  • Simplified session handling (onl y three methods!)
  • Works in parallel with built-in PHP sessions

INSTALLATION

Installation of mSess is simple. Just include it:

require("mSess.inc");

include("mSess.inc");

In your PHP script and create as many instances of the mSess object as you need (you need to configure each one, of course).

You will also need to create the database tables needed by mSess. The schema is located in the create_sessions_storage.sql file included in the downloadable archive. Load it into the database of your choosing and it will create a new table called "sessions". By design, several web-sites/apps may share a single sessions database/table as long as the PHP session manager can keep track of unique session IDs, otherwise users might get served the wrong session data -- BEWARE! Configure accordingly and to taste.

Take a look at the included sample php scripts to get an idea how to use and configure the mSess object. You can see them in action by putting the mSess folder in a web accessible area, and pointing your browser at http://yourserver/mSess/page1.php after setting up the sessions table in your database.

REQUIREMENTS

This PHP class has been tested extensively on PHP5.2.5, and should have no problems working with that and better.

Internally, the only "external" requirements are support for the WDDX and MySQLi extensions (yes, we are using the improved extension).

As the distributable version of the class is encoded and encrypted using the IonCube Encoder you will also need to add the IonCube Loader to your extensions by editing your php.ini file. You can get the instructions and download the necessary binaries here:

http://www.ioncube.com/

DONATIONWARE

mSess is provided to the PHP community at large for no cost (see the license agreement -- LICENSE.TXT and LICENSE.PDF -- for complete terms), but it did take time and effort to build and continues to take time and effort to enhance and fix. If you really find it useful or have really benefitted from using it, or you just want to show appreciation please donate USD5.00 to paypal@virtualthinking.com with a nice note on how it's helping you. It's a real vote of confidence and encouragement :).

Just click the shiny button below:

In any case, hope that you will enjoy this piece of software and that it helps you when you need it most!

GET IT

DOWNLOAD

BUG REPORTS

Please send bug reports to: msess at virtualthinking.com

Listed at Hot Scripts in PHP