2

Fatal error: Class CI_Session_files_driver contains 1 abstract method and must therefore be declared abstract or implement the remaining methods (SessionHandlerInterface::open) in C:\xampp\htdocs\cmms2\system\libraries\Session\drivers\Session_files_driver.php on line 49

this error keeps on showing up while i'm working on my localhost xampp web app projec. I'm using codeigniter by the way. What do you think is the reason this shows up? These are the only codes that I've done with session.

  $this->session->set_userdata($data);
    $autoload['libraries'] = array('database','session');
    $config['sess_driver'] = 'files';
    $config['sess_cookie_name'] = 'ci_session';
    $config['sess_expiration'] = 7200;
    $config['sess_save_path'] = sys_get_temp_dir();
    $config['sess_match_ip'] = FALSE;
    $config['sess_time_to_update'] = 300;
    $config['sess_regenerate_destroy'] = FALSE;
hale
  • 171
  • 2
  • 5
  • 12
  • show which class are u using for extend? – devpro Jan 20 '16 at 09:35
  • CI_Session_driver is an abstract class. you need to extend with CI_Session class. – devpro Jan 20 '16 at 09:37
  • @devpro posted the codes that i dealt with session – hale Jan 20 '16 at 09:42
  • check which class r u using for extend??? if you are extending with CI_Session_driver just change with CI_Session – devpro Jan 20 '16 at 09:44
  • @treblaluch i need your code as well – Abdulla Nilam Jan 20 '16 at 09:44
  • @Abdulla what code are u talking about? those are the only ones i've dealt with code igniter – hale Jan 20 '16 at 09:45
  • @devpro you mean in the session_files_driver.php? its extending CI_Session_driver – hale Jan 20 '16 at 09:46
  • yes, You need to extend CI_Session, not CI_Session_files_driver. – devpro Jan 20 '16 at 09:48
  • @devpro class CI_Session_files_driver extends CI_Session_driver implements SessionHandlerInterface this is what it looks like. I changed but there is an error. – hale Jan 20 '16 at 09:50
  • You shouldn't change System files. – Tpojka Jan 20 '16 at 11:08
  • @Tpojka i didn't change anything. just those session files. but why des this error occurs. since i upgraded to the new xampp with php 7. – hale Jan 20 '16 at 11:16
  • How do you mean "just those session files"? - everything should work without any changes. For php version related question, I'm suggesting you to ask on [their forum](http://forum.codeigniter.com). – Tpojka Jan 20 '16 at 11:20
  • @Tpojka i mean those codes are the only ones i have touched. Are you good in codeigniter? – hale Jan 20 '16 at 11:33
  • Nothing shouldn't be changed in `system` directory. Is code you posted here in one or multiple files? Autoload should be in `$config` array of `APPPATH . 'config/autoload.php'` file, `$config['sess_save_path']` should be string of absolute path, NOT temporary directory. Lot of code here doesn't fit CodeIgniter [docs](https://codeigniter.com/userguide3/). – Tpojka Jan 20 '16 at 11:51
  • @Tpojka any suggestions on sess_save_path? autload is in autoload.php i posted it their because i configured it and its related to session. – hale Jan 20 '16 at 12:58
  • You can check suggestion and recomendation in comments for any line in file. Just above the the config line, there is comment that explains what should you set and how. [Config file](https://github.com/bcit-ci/CodeIgniter/blob/develop/application/config/config.php). – Tpojka Jan 20 '16 at 13:12
  • Possible duplicate of [Intermittent PHP Abstract Class Error](https://stackoverflow.com/questions/42503240/intermittent-php-abstract-class-error) – Narf Oct 18 '17 at 10:51

3 Answers3

8

Please restart apache server if not working then download CodeIgniter again and replace your system/ directory with a fresh one.

  • It work for me. I have just restart my apache server. Thanks for it – Mohd Hasan Jul 14 '18 at 07:34
  • Right, it's just a problem of apache server some time we use our system on sleep mode for a while and then it's happen. At first it's spoil the mind because in error we didn't get any thing which relate with the apache server. – heySushil Apr 04 '20 at 09:56
  • yep! happened all of a sudden to my perfectly working CI app after my machine remained for couple of hours on standby, Apache restart fixed it right away! – Anupam Oct 06 '20 at 09:08
  • It works. +1 for this solution. – chirag p Oct 04 '21 at 10:58
0

Edit: This is a PHP bug that in my observation triggers on Windows, Apache+mod_php.

(old answer below)


SessionHandlerInterface::open() is implemented by system/libraries/Session/drivers/Session_files_driver.php in CodeIgniter.

The only way to trigger the error you've shown is by modifying that file, which you're not supposed to do.

Narf
  • 14,600
  • 3
  • 37
  • 66
  • It's not that simple, I've encountered this error at random time, many time, even tough I'm absolutely never modify that file and I always use new copy of CodeIgniter when start creating a project. I'd guess that this is a "rare bug" of CI which could happen on PHP7 in certain environment/machine ... IDK – Taufik Nur Rahmanda Oct 18 '17 at 06:30
  • You're right, it's not that simple. It's funny that right after that you assume it is a CI issue though. – Narf Oct 18 '17 at 10:48
  • Is this issue happen on other framework as well? (because I only use CI) – Taufik Nur Rahmanda Oct 18 '17 at 11:21
  • `CI_Session_files_driver` is belong to CI, isn't it? That's why I thought it be. – Taufik Nur Rahmanda Oct 18 '17 at 11:22
  • Yes it does happen in other frameworks (and I had already updated the answer to reflect this), but that's besides the point. If you actually look at the code, you'll know there's no way this is the framework's fault. – Narf Oct 18 '17 at 11:31
0

Go in System folder /system/libraries/Session

Then comment the code in SessionHandlerInterface.php

interface SessionHandlerInterface {

// public function open($save_path, $name);
// public function close();
// public function read($session_id);
// public function write($session_id, $session_data);
// public function destroy($session_id);
// public function gc($maxlifetime);
}

Let's try your code is working or not

Robert
  • 5,278
  • 43
  • 65
  • 115