Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Class Functions Multiple Times

Featured Replies

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();

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

  • 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?

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

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

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.