CodeIgniter Forums
[Solved] Session dont working - Class 'database' not found - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forum-28.html)
+--- Forum: CodeIgniter 4 Support (https://forum.codeigniter.com/forum-30.html)
+--- Thread: [Solved] Session dont working - Class 'database' not found (/thread-71964.html)

Pages: 1 2


[Solved] Session dont working - Class 'database' not found - NespiCMS - 10-18-2018

Hello!

I create session variable - $session=\Config\Services:Confusedession();
But I get an error in the logs - Class 'database' not found
For any of the database driver options (files, database), I get this error. 
(Class 'files' not found - if sessions driver set is "files").

Help please.


RE: Session dont working - Class 'database' not found - ciadmin - 10-19-2018

Check application/Config/App ... in CI4, you provide the name of the session handling class, eg 'CodeIgniter\Session\Handlers\FileHandler', instead of just 'files'.


RE: Session dont working - Class 'database' not found - NespiCMS - 10-19-2018

settings from docs:

public $sessionDriver   = 'database';
public $sessionSavePath = 'ci_sessions';



You mean it should be like this?

public $sessionDriver   = 'CodeIgniter\Session\Handlers\DatabaseHandler';
public $sessionSavePath = 'ci_sessions';



or what?


RE: Session dont working - Class 'database' not found - ciadmin - 10-19-2018

That is right. I think you just uncovered an error in the user guide Undecided

I have raised a bug report!


RE: Session dont working - Class 'database' not found - NespiCMS - 10-19-2018

Settings
public $sessionDriver            = 'CodeIgniter\Session\Handlers\DatabaseHandler';
public $sessionSavePath          = 'ci_sessions';

it still does not work - CRITICAL - 2018-10-19 02:46:06 --> Object of class CodeIgniter\Session\Handlers\DatabaseHandler could not be converted to string


RE: Session dont working - Class 'database' not found - ciadmin - 10-19-2018

Oh dear - then I have misinterpreted something somewhere Undecided Will dig further.


RE: Session dont working - Class 'database' not found - ciadmin - 10-19-2018

Where is that error message happening. The source code looks like it expects a class name.


RE: Session dont working - Class 'database' not found - NespiCMS - 10-19-2018

Problem is here:
$driver = new $driverName($config); (System\Config\Services - line 679)
where $driverName is "database" (from application\Config\App)
but class "database" is missing

What class should the variable be equal here?


RE: Session dont working - Class 'database' not found - NespiCMS - 10-19-2018

Sorry, my mistake, this:
public $sessionDriver            = '\CodeIgniter\Session\Handlers\DatabaseHandler';

work fine, thanks a lot!


RE: Session dont working - Class 'database' not found - ciadmin - 10-19-2018

Smile