I had this problem after I created a new CodeIgniter 4 project with Composer.
Normally sessions are saved in the folder specified in php.ini with setting session.save_path. You can check this by calling
phpinfo();
and look for
session.save_path
I was surprised to find out that the CodeIgniter tries to save the data in a different folder. It is configured in file app/Config/Paths.php. The variable to look for is
$writableDirectory
The (default) line of code is
public string $writableDirectory = __DIR__ . '/../../writable
I tried to remove the readonly flag from the folder, but that didn't work. Some process or application kept me from removing it. (I suspected Google Drive). Note: I am on Windows, but that doesn't really matter... I think.
Creating a new folder named "writable2" next to it and changing the setting to
public string $writableDirectory = __DIR__ . '/../../writable2
solved the problem.
Still don't know which process or application changed (and kept on changing) the folder to readonly. Changing the name back from writable2 to writable and the problem is back.
Deleting folder writable and renaming folder writable2 to writable works though. Weird!