Reputation: 221
An uncaught Exception was encountered
Type: Exception
Message: Session: Configured save path 'C:\Windows\Temp' is not writable by the PHP process.
Filename: prm\system\libraries\Session\drivers\Session_files_driver.php
Line Number: 125
Backtrace:
File: \prm\application\controllers\login.php Line: 8 Function: __construct
File: \prm\index.php Line: 279 Function: require_once
Not able to fix this issue. please suggest how to fix this
Upvotes: 6
Views: 40930
Reputation: 5052
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!
Upvotes: 0
Reputation: 29
This error basically tells you that the PHP process does not have the permission to write to the cache directory specified in your config.
The simplest, clearest solution would be to grant write permission for the directory.
I don't use a windows machine so I can't tell you exactly how to do it, but you can look that up.
Upvotes: 0
Reputation: 827
Edit config.php
Location: application/config/config.php
Before
$config['sess_driver'] = 'files';
$config['sess_cookie_name'] = 'ci_session';
$config['sess_expiration'] = 7200;
$config['sess_save_path'] = NULL;
$config['sess_match_ip'] = FALSE;
$config['sess_time_to_update'] = 300;
$config['sess_regenerate_destroy'] = FALSE;
After
$sessDir = session_save_path();
$sessDir = "{$sessDir}/sessionPath";
is_dir($sessDir)?:mkdir($sessDir);
$config['sess_driver'] = 'files';
$config['sess_cookie_name'] = 'ci_session';
$config['sess_expiration'] = 7200;
$config['sess_save_path'] = $sessDir;
$config['sess_match_ip'] = FALSE;
$config['sess_time_to_update'] = 300;
$config['sess_regenerate_destroy'] = FALSE;
It's work for me
Upvotes: 11
Reputation: 63
In your application's config.php file search for $config['sess_save_path'] change its default value of sys_get_temp_dir() to another publicly accessible directory preferably not in the C: drive.
or you can set it globally in your php.ini file and call ini_get ('session.save_path'), but first make sure you have changed the default value of that option to a temp directory of your choice.
Upvotes: 1
Reputation: 1090
We are setting up 'C:\Windows\Temp' windows directory path to database ci_session table.
change the following in your config file.
$config['sess_driver'] = 'files';
$config['sess_cookie_name'] = 'ci_session';
$config['sess_expiration'] = 7200;
$config['sess_save_path'] = NULL;
$config['sess_match_ip'] = FALSE;
$config['sess_time_to_update'] = 300;
$config['sess_regenerate_destroy'] = FALSE;
to
$config['sess_driver']= 'database';
$config['sess_cookie_name']= 'mycookie';
$config['sess_expiration']= 0;
$config['sess_save_path']= 'ci_session';
$config['sess_match_ip']= FALSE;
$config['sess_time_to_update']= 300;
$config['sess_regenerate_destroy']= FALSE;
$config['sess_use_database']= TRUE;
$config['sess_expire_on_close']= TRUE;
$config['sess_table_name']= 'ci_session';
Upvotes: 15