Welcome Guest, Not a member yet? Register   Sign In
Using redis to store sessions
#1

Hi

Using php7 FPM, CodeIgniter 3.1.2, Redis 3.0.3.

After struggling for few hours finding the best setup for using Redis as store engine for sessions I find myself even more confused.
I have tried the following setups, and I will be glad if you have some insights of how this should be working.

Setup 1: 
codeignier config
PHP Code:
$config['sess_driver'         'redis';
$config['sess_save_path'      'tcp://redis_server_ip:server_port?auth=password&database=0&timeout=604800'


php.ini as left with default configuration.
used session_write_close() immediately after updating session data.

Result: 
Codeigniter is using Redis for storing sessions but then I came across this error on heavy ajax pages:
Session: Session: Error while trying to free lock for ci_session:cq399b646bc6lstdhrcrb69k7nvu42r8:lock
I understand the logic and need of lock mechanism but anyway, it seems like CodeIgniter is not handling multiple ajax requests simultaneously.

Setup 2:
codeignier config
PHP Code:
$config['sess_driver'         'files'

php.ini 
Code:
session.save_handler = redis
session.save_path = "tcp://redis_server_ip:server_port?auth=password&database=0&timeout=604800"

Result:
nothing works!
I get the following error: 
Message: is_dir(): Unable to find the wrapper "tcp" - did you forget to enable it when you configured PHP?
Filename: drivers/Session_files_driver.php
Line Number: 134

Do you guys have any idea of what should be the best way to use redis for storing sessions?
Reply
#2

(11-01-2016, 01:17 PM)eranhazout Wrote: Hi

Using php7 FPM, CodeIgniter 3.1.2, Redis 3.0.3.

After struggling for few hours finding the best setup for using Redis as store engine for sessions I find myself even more confused.
I have tried the following setups, and I will be glad if you have some insights of how this should be working.

Setup 1: 
codeignier config
PHP Code:
$config['sess_driver'         'redis';
$config['sess_save_path'      'tcp://redis_server_ip:server_port?auth=password&database=0&timeout=604800'


php.ini as left with default configuration.
used session_write_close() immediately after updating session data.

Result: 
Codeigniter is using Redis for storing sessions but then I came across this error on heavy ajax pages:
Session: Session: Error while trying to free lock for ci_session:cq399b646bc6lstdhrcrb69k7nvu42r8:lock
I understand the logic and need of lock mechanism but anyway, it seems like CodeIgniter is not handling multiple ajax requests simultaneously.

That's the entire point of locking.

(11-01-2016, 01:17 PM)eranhazout Wrote: Setup 2:
codeignier config
PHP Code:
$config['sess_driver'         'files'

php.ini 
Code:
session.save_handler = redis
session.save_path = "tcp://redis_server_ip:server_port?auth=password&database=0&timeout=604800"

Result:
nothing works!
I get the following error: 
Message: is_dir(): Unable to find the wrapper "tcp" - did you forget to enable it when you configured PHP?
Filename: drivers/Session_files_driver.php
Line Number: 134

This can't possibly work ...
Reply
#3

Ok, So any other way to make it work and support simultaneous ajax requests?
Reply
Reply
#5

Ok, I have already created my custom session library.
I will publish it on github soon.
Thanks
Reply




Theme © iAndrew 2016 - Forum software by © MyBB