While I’ve been using the database session data handler in the CodeIgniter framework for some time, upon reading this thread at PHPBuilder forums I decided it was time to write my own. In part I just wanted to gain a more thorough understanding of the process, and I also figured I could use it some day for a small project that does not require the power of CodeIgniter or something similar.
I decided to use an OOP approach for this, creating two classes. One class, SessionHandler, would be the interface the client code will use to establish the session-handler functions. A second class, SessionData, would handle the actual interface with the database. For now it uses the MySQLi database
interface; but if I wanted to use PDO or something else, I would just need to either edit the SessionData class appropriately, or even go to some sort of abstract factory pattern, perhaps, to instantiate a DBMS-specific class. For now, though, I’ll just keep it “simple” with only the MySQLi class.
