I got this error after install a new xampp version. and clone my codeigniter project.
Message: Return type of CI_Session_files_driver::open($save_path, $name)
should either be compatible with SessionHandlerInterface::open(string $path, string $name):
bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice
Filename: drivers/Session_files_driver.php
Line Number: 132
CodePudding user response:
For anyone else that comes across this error, I also experienced it after upgrading to PHP 8.1. The only way I could find to "fix" it was be adding #[\ReturnTypeWillChange] before the open, read, write, close, destroy and gc functions in /system/libraries/Session/drivers/Session_files_driver.php. For example:
#[\ReturnTypeWillChange]
public function open($save_path, $name)
{
...
CodePudding user response:
I experienced this error after re installing XAMPP Server. I have fixed this issue by adding
#[\ReturnTypeWillChange]
for all methods (open, read, write, close, destroy and gc) in Session_files_driver.php file. The file can find in project folder system/libaries/Session/drivers/Session_files_driver.php
#[\ReturnTypeWillChange]
public function open($save_path, $name)
{
...
}
#[\ReturnTypeWillChange]
public function read($session_id)
{
...
}
#[\ReturnTypeWillChange]
public function write($session_id, $session_data)
{
...
}
#[\ReturnTypeWillChange]
public function close()
{
...
}
#[\ReturnTypeWillChange]
public function destroy($session_id)
{
...
}
#[\ReturnTypeWillChange]
public function gc($maxlifetime)
{
...
}
