Welcome Guest, Not a member yet? Register   Sign In
Redis empty session - Severity: Warning --> Unknown: Failed to write session data (us
#1

I am using Codeigniter 3.0.4 build. My redis version is 2.4.6

When user logs off or deletes their account, i am calling

   
Code:
$this->session->sess_destroy();


if( isset($_COOKIE[REMEMBER_ME_TOKEN]) ) {
    unset($_COOKIE[REMEMBER_ME_TOKEN]);
   setcookie(REMEMBER_ME_TOKEN, NULL, time()-(2*24*60*60), '/');
}

redirect('login');

My login page is a cached page and browser (firefox) sometimes does not send request to server at all.

If user submits the login form at this point, serever throws an error
Severity: Warning --> Unknown: Failed to write session data (user). Please verify that the current setting of session.save_path is correct (e:/wamp/tmp) Unknown 0


Using log statements, i identified that $session_data was empty and write returns failure
Code:
CI_Session_redis_driver::write {
...
        return ($this->_redis->setTimeout($this->_key_prefix.$session_id, $this->_config['expiration']))
               ? $this->_success
               : $this->_failure;

}

CI_Session_redis_driver::write function


I am trying to fix this by adding a check in the redis session driver's write function and returning success if session data was empty

PHP Code:
CI_Session_redis_driver::write {

    if(empty(
$session_data)) {
        return 
$this->_success;
    }

    ...
}
                      


Is this the correct way to handle empty session data? If not, how it should be handled?
Reply
#2

No, what you're doing is wrong.

This is a bug that's already fixed in 3.0.5-dev: https://github.com/bcit-ci/CodeIgniter/pull/4424
Reply
#3

Thankyou Narf, I pulled the fix.
Thanks to jonty-comp for the fix.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB