'Message: Return type of CI_Session_files_driver::open($save_path, $name) should either be compatible with [duplicate]

I got this error after install a new xampp version (php8). 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



Solution 1:[1]

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)
{
  ...
}

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Joyal George