CodeIgniter Forums

Full Version: Memcached session storage driver error
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello. Thanks for your Work.

I tried to use Memcached instead of database for Session storage (on  CodeIgniter 3.1.6):
PHP Code:
$config['sess_driver'] = 'memcached';
$config['sess_cookie_name'] = 'wsc_sessions';
$config['sess_expiration'] = 7200;
$config['sess_save_path'] = 'localhost:11211';
$config['sess_match_ip'] = FALSE;
$config['sess_time_to_update'] = 7200;
$config['sess_regenerate_destroy'] = FALSE

But there was an error:
Warning: Uncaught Error: Class 'Memcached' not found in /system/libraries/Session/drivers/Session_memcached_driver.php:108 Stack trace: 
#0 [internal function]: CI_Session_memcached_driver->open('/var/lib/php/se...', 'wsc_sessions') 
#1 /system/libraries/Session/Session.php(143): session_start() 
#2 /system/core/Loader.php(1279): CI_Session->__construct() 
#3 /system/core/Loader.php(1172): CI_Loader->_ci_init_library('Session', 'CI_', NULL, 'session') 
#4 /system/core/Loader.php(1037): CI_Loader->_ci_load_stock_library('Session', 'Session/', NULL, NULL) 
#5 /system/core/Loader.php(1083): CI_Loader->_ci_load_library('Session', NULL, NULL) 
#6 /system/core/Loader.php(218): CI_Loader->_ci_load_library('Session', NULL, NULL) 
#7 /application/controllers/Wifi.php(11): CI_ in /system/libraries/Session/drivers/Session_memcached_driver.php on line 108 Fatal error: session_start(): Failed to initialize storage module: user (path: /var/lib/php/sessions) in /system/libraries/Session/Session.php on line 143
Well taking a guess I'll bet that you need to re-install CodeIgniter deleting the ./system folder.
Thanks for your reply.

I followed your advice and reinstalled the CodeIgniter 3.1.6 by deleting the ./system folder, but the error remained the same.

PS: I use the Memcached (with the path:localhost:11211for another project (CMS Bitrix24) on the same server, but there is no such error
(11-14-2017, 12:05 PM)InsiteFX Wrote: [ -> ]Well taking a guess I'll bet that you need to re-install CodeIgniter deleting the ./system folder.

Dude, stop making guesses. If you don't know how to help, you don't have to reply.
The Memcached class is part of a PHP extension.

(11-14-2017, 12:30 PM)Andrey Wrote: [ -> ]Thanks for your reply.

I followed your advice and reinstalled the CodeIgniter 3.1.6 by deleting the ./system folder, but the error remained the same.

PS: I use the Memcached (with the path:localhost:11211for another project (CMS Bitrix24) on the same server, but there is no such error

On the same server? Really? There's three options:

1. It's not on the same server.
2. It's not Memcached, but Memcache (no 'd' at the end; different PHP extension).
3. That server has multiple PHP versions installed, or that other application uses a different PHP SAPI; either way - the one you're using with CI doesn't have Memcached enabled.
(11-14-2017, 05:50 PM)Narf Wrote: [ -> ]On the same server? Really? There's three options:

1. It's not on the same server.
2. It's not Memcached, but Memcache (no 'd' at the end; different PHP extension).
3. That server has multiple PHP versions installed, or that other application uses a different PHP SAPI; either way - the one you're using with CI doesn't have Memcached enabled.

Um, actually there's a 4th option - that other app isn't running PHP at all.
(11-14-2017, 05:50 PM)Narf Wrote: [ -> ]2. It's not Memcached, but Memcache (no 'd' at the end; different PHP extension).

You're right: on the server php-memcache was installed but there was no php-memcached.
I fixed it and the error was gone.

Thank you for your help.