Switching to memcache for sessions - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5) +--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24) +--- Thread: Switching to memcache for sessions (/showthread.php?tid=73439) |
Switching to memcache for sessions - priyankaamonker - 04-24-2019 Hello, I need to save sessions to memcache instead of files in my local instance of codeignitor. This is what I did: Step 1 : updated config.php $config['sess_driver'] = 'memcached'; $config['sess_save_path'] = 'localhost:11211'; Step 2: update php.ini session.save_handler=memcached session.save_path="tcp://localhost:11211?persistent=1&weight=1&timeout=1&retry_interval=15" Step 3: Restart apache This works fine. Now when I need to deploy this to the server, I came to know that I am not allowed to update the ini settings because Im using shared services. My question is: how do I set session.save_handler and session.save_path via code in codeignitor and not depend on updating php.ini of the server? RE: Switching to memcache for sessions - donpwinston - 04-24-2019 You might be able to do it in an .htaccess file in your doc root. RE: Switching to memcache for sessions - dave friend - 04-24-2019 (04-24-2019, 03:48 PM)priyankaamonker Wrote: Hello, I don't believe that you need to set php.ini directly. First of all, CodeIgniter will set the session.save_handler based on $config['sess_driver'] . CodeIgniter would ignore the php.ini setting for session.save_handler as it sets up its own SessionHander class to attend to all the open/close, read/write, etc chores for managing Sessions. Second, session.save_path can be and is set via PHP Code: ini_set('session.save_path', config_item('sess_save_path')); In short, your $config settings should be all you need. IMO, find a different ISP because neither of those items should affect a shared server that is properly set up. RE: Switching to memcache for sessions - priyankaamonker - 04-24-2019 Thanks for replying to my query! I see that in Session_files_driver it does; ini_set('session.save_path', $this->_config['save_path']); // setting the php.ini But does not do anything similar in Session_memcache_driver. I tried adding it in the __contruct but that dint work. Im using CI version 3.3.0 RE: Switching to memcache for sessions - dave friend - 04-25-2019 (04-24-2019, 11:13 PM)priyankaamonker Wrote: Thanks for replying to my query! True it does not call ini_set('session.save_path', ..., but it doesn't need to. The Memcached driver does not use 'session.save_path' from php.ini. It only needs/uses a value from $this->_config['save_path']. Is it not working using just the $config items? RE: Switching to memcache for sessions - priyankaamonker - 04-25-2019 (04-25-2019, 09:00 AM)dave friend Wrote:(04-24-2019, 11:13 PM)priyankaamonker Wrote: Thanks for replying to my query! Thanks for answering my question! How do I verify that my sessions I being saved in memcache and not in files. What is the key used in codeignitor to save sessions? |