November 25, 201015 yr Hello, Im currently have issues with my class, It seems that my class "$DSecurity" and function "mss" is only working once, It works perfectly fine untill it gets to the _write function then i get the following error: Fatal error: Call to a member function mss() on a non-object in C:\xampp\htdocs\index.php on line 50 I know the function works perfectly fine, Its Asif it can not be used multiple times. // Require Classes require('core/global_classes/security.class.php'); require('core/global_classes/database.class.php'); // Session Set Save session_set_save_handler('_open', '_close', '_read', '_write', '_destroy', '_clean'); function _open() {} function _close() {} function _read($id) { global $DSecurity, $DBHandler; $id = $DSecurity->mss($id); return $DBHandler->DoQuery("SELECT * FROM sc_sessions WHERE id='$id'"); } function _write($id, $data) { global $DSecurity, $DBHandler; $id = $DSecurity->mss($id); $data = $DSecurity->mss($data); $time = $DSecurity->mss(time()); return $DBHandler->DoQuery("REPLACE INTO sc_sessions (`id`, `data`, `time`) VALUES ('$id', '$data', '$time')"); } function _destroy($id) { } function _clean($max) { $max = mysql_real_escape_string($max); $max = time() - $max; mysql_query("DELETE FROM sc_sessions WHERE time > $max"); } // Session Start session_start();
November 25, 201015 yr Hello, Im currently have issues with my class, It seems that my class "$DSecurity" and function "mss" is only working once, It works perfectly fine untill it gets to the _write function then i get the following error: Fatal error: Call to a member function mss() on a non-object in C:\xampp\htdocs\index.php on line 50 I know the function works perfectly fine, Its Asif it can not be used multiple times. // Require Classes require('core/global_classes/security.class.php'); require('core/global_classes/database.class.php'); // Session Set Save session_set_save_handler('_open', '_close', '_read', '_write', '_destroy', '_clean'); function _open() {} function _close() {} function _read($id) { global $DSecurity, $DBHandler; $id = $DSecurity->mss($id); return $DBHandler->DoQuery("SELECT * FROM sc_sessions WHERE id='$id'"); } function _write($id, $data) { global $DSecurity, $DBHandler; $id = $DSecurity->mss($id); $data = $DSecurity->mss($data); $time = $DSecurity->mss(time()); return $DBHandler->DoQuery("REPLACE INTO sc_sessions (`id`, `data`, `time`) VALUES ('$id', '$data', '$time')"); } function _destroy($id) { } function _clean($max) { $max = mysql_real_escape_string($max); $max = time() - $max; mysql_query("DELETE FROM sc_sessions WHERE time > $max"); } // Session Start session_start(); That errors basically saying $DSecurity is not an object
November 25, 201015 yr Author That errors basically saying $DSecurity is not an object I know, but it is, As the _read function would of triggerd the error before the _write function, so hows that possible?
November 25, 201015 yr I know, but it is, As the _read function would of triggerd the error before the _write function, so hows that possible? Mmmm thats what im trying to figure out by looking at ur code
November 26, 201015 yr This is the same error that you had in the last post, all objects are destroyed by the time _write is called, so you need to write-close your sessions before PHP does. register_shutdown_function('session_write_close');
Create an account or sign in to comment