We configure our project (CodeIgniter 4) to use the default suggested by CodeIgniter for session configuration, we only changed the name of the cookie.
We grant the permissions to the session directory in Ubuntu:
cd /var/www/html/website
chmod -R 755 writable/
chown -R www-data:www-data writable/
There is no ajax or anything else, just normal access with views.
But as soon as we run the project, the error appears in the log:
ERROR - 2024-05-03 18:19:45 --> Session: Unable to obtain lock for file '/var/www/html/website/writable/session/mysession....4vpq81...psa3h'.
CRITICAL - 2024-05-03 18:19:45 --> ErrorException: session_start(): Failed to read session data: user (path: /var/www/html/website/writable/session)
in SYSTEMPATH/Session/Session.php on line 919.
1 [internal function]: CodeIgniterDebugExceptions->errorHandler()
2 SYSTEMPATH/Session/Session.php(919): session_start()
3 SYSTEMPATH/Session/Session.php(241): CodeIgniterSessionSession->startSession()
4 SYSTEMPATH/Config/Services.php(699): CodeIgniterSessionSession->start()
5 SYSTEMPATH/Config/BaseService.php(258): CodeIgniterConfigServices::session()
6 SYSTEMPATH/Config/BaseService.php(199): CodeIgniterConfigBaseService::__callStatic()
7 SYSTEMPATH/Config/Services.php(664): CodeIgniterConfigBaseService::getSharedInstance()
8 SYSTEMPATH/Config/BaseService.php(258): CodeIgniterConfigServices::session()
9 APPPATH/Controllers/Login.php(16): CodeIgniterConfigBaseService::__callStatic()
10 SYSTEMPATH/CodeIgniter.php(915): AppControllersLogin->__construct()
11 SYSTEMPATH/CodeIgniter.php(494): CodeIgniterCodeIgniter->createController()
12 SYSTEMPATH/CodeIgniter.php(361): CodeIgniterCodeIgniter->handleRequest()
13 FCPATH/index.php(79): CodeIgniterCodeIgniter->run()
My session config:
<?php
namespace Config;
use CodeIgniterConfigBaseConfig;
use CodeIgniterSessionHandlersFileHandler;
class Session extends BaseConfig
{
public string $driver = FileHandler::class;
public string $cookieName = 'mysession';
public int $expiration = 7200;
public string $savePath = WRITEPATH . 'session';
public bool $matchIP = false;
public int $timeToUpdate = 300;
public bool $regenerateDestroy = false;
public ?string $DBGroup = null;
}
What could be happening?