'Using PHP Sessions for High Traffic with AJAX and CodeIgniter
I was reading the CodeIgniter 3 documentation on using sessions and high traffic with AJAX, and it recommends using session_write_close().
My application has functions that write and read directly from $_SESSION, as an example below.
function setSession($index, $value) {
$_SESSION[$index] = $value;
}
function getSession($index) {
if (isset($_SESSION[$index]) {
return $_SESSION[$index];
} else {
return FALSE;
}
}
From what I understand from the documentation these two functions should always have session_start() at the beginning and session_write_close() at the end, correct?
That way they will avoid block the session and even the other requests being faster, since the session is unblocked.
Another issue that I found strange, CodeIgniter already has by default a session_start() function that is automatically triggered at the beginning of execution, without intervention from my code.
What will happen to this default session_start() if my functions were to call it every time something was fetched from the session?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
