CodeIgniter Forums
session problem - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Development (https://forum.codeigniter.com/forumdisplay.php?fid=6)
+--- Forum: CodeIgniter 3.x (https://forum.codeigniter.com/forumdisplay.php?fid=17)
+--- Thread: session problem (/showthread.php?tid=1095)



session problem - sintakonte - 02-11-2015

Hey guys, 
i could need some advice - because i'm experiencing a randomized session error from time to time and i don't know whats going on;
Whats the matter:
I'm losing from time to time my session

My Environment:

  • Apache 2.4.9
  • PHP 5.5.13
  • session.save_handler = redis 
  • in php.ini
  • CI V3 RC2
  • a modified version of Wiredesignz HMVC for CI
CI Config:
PHP Code:
$config['sess_driver']        = 'redis';
$config['sess_cookie_name']    = 'app';
$config['sess_expiration']    = 31536000;
$config['sess_match_ip']    = FALSE;
$config['sess_time_to_update']    = 300;
$config['sess_save_path'      "tcp://127.0.0.1:6379"


Error / Debug Messages from the log.php
Code:
DEBUG - 2015-02-11 14:30:28 --> Total execution time: 9.1220

ERROR - 2015-02-11 09:58:08 --> Severity: Notice --> Undefined variable: session_id \system\libraries\Session\drivers\Session_redis_driver.php 384

ERROR - 2015-02-11 09:58:08 --> Session: Error while trying to free lock for ci_session:


I can reproduce the error - because it seems its related to ajax calls (but not all, just a few)
And only those where the execution time is really long (because of other SOAP webservices etc.)

Any advice is much appreciated;

If you need more info - pls let me know;

thx in advance


RE: session problem - Narf - 02-11-2015

https://github.com/bcit-ci/CodeIgniter/commit/00025885b8042114c3b1859855656a94316b4e57

However, I'm not sure if anything could be done about long execution times ... Emulated locks, such as those that we do for Redis, can't be held forever and there has to be some time value associated with them. I'd reconsider my approach if any page load takes more than 5 seconds, especially for AJAX calls.


RE: session problem - sintakonte - 02-11-2015

thx Narf

about reconsidering the approach - i've no choice, my APP depends on other SOAP Services and this Navision Webservices are not in my hands right now ...


RE: session problem - Narf - 02-11-2015

That you don't have control over the remote service is not the problem ... I'd ask the following questions:

- Do those SOAP calls really need to be executed during a page load?
- Does the session have to be active during those SOAP calls? (you can open, read & close beforehand)
- Do you really need to use Redis for session storage?


RE: session problem - Narf - 02-14-2015

Added notes to the docs: https://github.com/bcit-ci/CodeIgniter/commit/b7cea9cab71352516ec290b09495d456c8db3e64