Search code examples
codeignitercodeigniter-4

NULL folder inside public folder on CI 4 project


What is NULL folder inside public folder in my CI 4 project? seems like session cookies. How to set folder name so not appear as NULL, Thank you

enter image description here

enter image description here


Solution

  • Here you opted for the Driver FileHandler of Codeigniter 4 which stores session in files. In order to work properly you also need to give him a session save path. Session configs are driven in the .env file and/or in app/Config/App.php.

    Example of the config in App.php file with a session save path :

    public $sessionDriver            = 'CodeIgniter\Session\Handlers\FileHandler';
    public $sessionCookieName        = 'ci_session';
    public $sessionExpiration        = 28000; // 8h
    public $sessionSavePath          = 'hello/world';
    public $sessionMatchIP           = false;
    public $sessionTimeToUpdate      = 300;
    public $sessionRegenerateDestroy = true;
    

    Watch out :
    It currently looks like that setting config in both files for the FileHandler driver is a bad idea. Setting it in App.php file seems a better option since it allows you to use multiple directories like dir1/dir2/my_session where this syntax catch an error in the .env file. But still be aware that the .env config ALWAYS takes over the one set in App.php