Fatal error: Uncaught Error: Class 'session' not found in C:\var\www\html\tools\inc\constants.php:122 Stack trace: #0 C:\var\www\html\tools\config.php(92): require_once() #1 C:\var\www\html\tools\header.php(1): require_once('C:\var\www\html...') #2 C:\var\www\html\tools\index.php(1): require_once('C:\var\www\html...') #3 {main} thrown in C:\var\www\html\tools\inc\constants.php on line 122
The code in question: lines 121-138
if(php_sapi_name() !== 'cli'){
$session = new session();
session_set_save_handler(array($session, 'open'),
array($session, 'close'),
array($session, 'read'),
array($session, 'write'),
array($session, 'destroy'),
array($session, 'gc'));
register_shutdown_function('session_write_close');
session_start();
}
if(DEBUG){
ini_set('xdebug.var_display_max_depth',-1);
ini_set('xdebug.var_display_max_data',-1);
ini_set('xdebug.var_display_max_children',-1);
set_time_limit(240);
}
I don't know how to fix it and I couldn't find anything online. I'm running php7 and I thought that there would be no issues. Is there anyway to fix this? I've tried calling other sessions and etc.
Another file that's called:
<?php
class session implements \SessionHandlerInterface {
public function __construct() {
// session_set_save_handler(
// array(&$this, 'open'),
// array(&$this, 'close'),
// array(&$this, 'read'),
// array(&$this, 'write'),
// array(&$this, 'destroy'),
// array(&$this, 'gc')
// );
// session_start();
// register_shutdown_function('session_write_close');
}
public function open($savePath, $session_name) {
$db = new database(TRUE);
$db->query("INSERT INTO session
SET session_id = :sessionName,
session_data = ''
ON DUPLICATE KEY
UPDATE session_lastaccesstime = NOW()");
$db->bind(':sessionName',$session_name);
$db->execute();
return true;
}
public function close() {
return true;
}
public function read($id) {
$db = new database(TRUE);
$db->query("SELECT * FROM session WHERE session_id = :id");
$db->bind(':id',$id);
if ($db->execute()) {
$result = $db->single(\PDO::FETCH_ASSOC);
return $result["session_data"].'';
}
return '';
}
public function write($id, $data) {
if ($data == null) {
return true;
}
$db = new database(TRUE);
$db->query("INSERT INTO session
SET session_id = ?,
session_data = ?
ON DUPLICATE KEY UPDATE session_data = ?");
$db->bind(1,$id);
$db->bind(2,$data);
$db->bind(3,$data);
$db->execute();
return true;
//session_write_close();
}
public function destroy($id) {
$db = new database(TRUE);
$db->query("DELETE FROM session WHERE session_id = :id");
$db->bind(':id',$id);
$db->execute();
return true;
}
public function gc($maxlifetime) {
$db = new database(TRUE);
$db->query("DELETE FROM session
WHERE session_lastaccesstime < DATE_SUB(NOW(),
INTERVAL " . $lifetime . " SECOND)");
$db->execute();
return true;
}
}
I tried loading in the class via placing
require_once("inc/classes/session.php")
right after the if statement, but that just opened up more issues and more classes not being called. I'll link to the GitHub so you can see what really is going on.
https://github.com/nfreader/newSS13tools
</div>