On the last few pages, we've talked about a bunch of little pieces that make up the sessions class. I thought I would take a minute and give you the complete class in one shot. class SessionManager { var $life_time; function SessionManager() { // Read the maxlifetime setting from PHP // Register this object as the session handler } function open( $save_path, $session_name ) { global $sess_save_path; $sess_save_path = $save_path; // Don't need to do anything. Just return TRUE. return true; } function close() { return true; } function read( $id ) { // Set empty result // Fetch session data from the selected database $time = time(); $newid = mysql_real_escape_string($id); $rs = db_query($sql); if($a > 0) { } return $data; } function write( $id, $data ) { // Build query $newid = mysql_real_escape_string($id); $sql = "REPLACE `sessions` $rs = db_query($sql); return TRUE; } function destroy( $id ) { // Build query db_query($sql); return TRUE; } function gc() { // Garbage Collection
// Build DELETE query. Delete all records who have passed db_query($sql); // Always return TRUE } }
blog comments powered by Disqus |
|
|
|
|
|
|
|