Welcome Guest, Not a member yet? Register   Sign In
Using Sessions for High Traffic with AJAX
#3

(This post was last modified: 05-19-2022, 07:26 AM by ElTomTom.)

I still use CodeIgniter version 3.

I'm basing myself on this sentence from the session documentation (Session Library — CodeIgniter 3.1.13 documentation):
Long story short - call session_write_close() once you no longer need anything to do with session variables. 

The problem is that sometimes I use session at the beginning of the code, then halfway through the code.

In this case from what I understand the best thing would be for my code to be like this, correct?

PHP Code:
function setSession($index$value) {

    if (session_status() === PHP_SESSION_NONE) {
        session_start();
    }

    $_SESSION[$index] = $value;

    session_write_close();
}

function 
getSession($index) {

    if (session_status() === PHP_SESSION_NONE) {
        session_start();
    }

    $value FALSE;

    if (isset($_SESSION[$index]) {
        $value $_SESSION[$index];
    }

    session_write_close();

Reply


Messages In This Thread
RE: Using Sessions for High Traffic with AJAX - by ElTomTom - 05-19-2022, 07:22 AM



Theme © iAndrew 2016 - Forum software by © MyBB