Vanilla 1 is no longer supported or maintained. If you need a copy, you can get it here.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

How to import vanilla session data into database

edited July 2009 in Vanilla 1.0 Help
I have created one class for submitting session data into database but when i called this class in index.php then it is not working can anybody tell me how to solve this include("appg/connection.php"); require_once("appg/sessions.php"); $sess = new SessionManager(); session_start(); code of my session.php file is as follows: <? class SessionManager { var $life_time; function SessionManager() { echo "hello"; // Read the maxlifetime setting from PHP $this->life_time = get_cfg_var("session.gc_maxlifetime"); // Register this object as the session handler print_r(session_set_save_handler( array( &$this, "open" ), array( &$this, "close" ), array( &$this, "read" ), array( &$this, "write"), array( &$this, "destroy"), array( &$this, "gc" ) )); } function open( $save_path, $session_name ) { echo "kam ho gaya"; 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 $data = ''; // Fetch session data from the selected database $time = time(); $newid = mysql_real_escape_string($id); $sql = "SELECT session_data FROM sessions WHERE session_id = '$newid' AND 'expires' > $time"; $rs = mysql_query($sql); $a = mysql_num_rows($rs); if($a > 0) { $row = mysql_fetch_assoc($rs); $data = $row['data']; } return $data; } function write( $id, $data ) { // Build query $time = time() + $this->life_time; $newid = mysql_real_escape_string($id); $newdata = mysql_real_escape_string($data); $sql = "Replace sessions(session_id,session_data,expires) VALUES('$newid','$newdata', $time)"; $rs = mysql_query($sql); return TRUE; } function destroy( $id ) { // Build query $newid = mysql_real_escape_string($id); $sql = "DELETE FROM sessions WHERE session_id ='$newid'"; mysql_query($sql); return TRUE; } function gc() { $sql = "DELETE FROM sessions WHERE expires < UNIX_TIMESTAMP();"; mysql_query($sql); // Always return TRUE return true; } } ?> can anybody help me to solve this problem its very urgent
Sign In or Register to comment.