PHP Sessions Management Class implements a new PHP session handler that can replace the default PHP session handler by storing session data in a MySQL database table. The session handler works just by creating an object of this class. After that, applications just need to use the same code to store and retrieve session variables.
| Tags | Software Development Libraries php classes |
|---|---|
| Operating Systems | OS Independent |
| Implementation | PHP |
Recent releases


Changes: 'LIMIT 1' has been added to the read() method, increasing the performance of the script.


Changes: The write method was rewritten; it previously had to run two queries each time and now only runs a single one (which uses ON DUPLICATE KEY UPDATE). The type of the http_user_agent field in the database table has been changed from TEXT to VARCHAR(32) as it's now MD5 hashed. This should increase the performance of the script. The constructor of the class now accepts a new argument "securityCode" in order to try to prevent HTTP_USER_AGENT spoofing.


Changes: The get_users_online() method is now more accurate as it now runs the garbage collector before getting the number of online users. The structure of the MySQL table used by the class was tweaked in so that the "http_user_agent" field was changed from VARCHAR(255) to TEXT to accomodate user agent strings that are longer than 255 characters. The "session_data" field was also changed from TEXT to BLOB to help users who store a large amount of data in sessions.


Changes: The class was trying to store the session data without processing it with mysql_real_escape_string. Therefore, whenever you had quotes in your data, nothing got saved. This problem has been fixed.


Changes: In the 'session_data' table, the 'session_id' field is now a primary key and its type was changed from varchar(255) to varchar(32). Previously, a whole table scan was performed every time a session was loaded. A new "stop()" method that unsets a session's variables and deletes it from the database was added due to the fact that some people were using the private "destroy" method, which is not for this purpose. You can now override the default settings of the session.gc_maxlifetime, session.gc_probability, and session.gc_divisor configuration options. An example file was added.