I have a username variable from WordPress, by including wp-config.php. If I use on my index page, I can run following and all is ok.
echo 'Username: ' . $current_user->user_login . "\n";
also I can call echo $_SESSION['username']; which both output the username.
I have an extended class that I am trying to pass this variable into. And I cannot seem to get it to work.
class elFinderVolumeMySQL extends elFinderVolumeDriver {
Does anyone please know how to do this. I have tried absolutely everything, but I am new to php and not well up on constructors extended classes and whether I am doing something really wrong here, which may cause me problems.
Any advice greatly apreciated.
ie I need to add to this to get all ids where equal to username.
protected function _scandir($id) {
$files = array();
$sql = 'SELECT f.id, f.parent_id, f.name, f.size, f.mtime, f.mime, f.width, f.height, ch.id AS dirs
FROM '.$this->tbf.' AS f
LEFT JOIN '.$this->tbf.' AS ch ON ch.parent_id=f.id
WHERE f.parent_id="'.$id.'"
GROUP BY f.id';
if ($res = $this->query($sql)) {
while ($r = $res->fetch_assoc()) {
$id = $r['id'];
$this->stat($id, false, $r);
$files[] = $id;
}
}
return $files;
}
$_SESSION is global by nature and is available across the script if following conditions are met:
Thus, if you are not able to access the value using $_SESSION[‘username’], then do check for the two conditions shared above. You can also check the destroying of session by creating a test variable under sessions and see if its value is available or not.
Hope this helps.