CI_Session::_ci_init_vars PHP Method

_ci_init_vars() protected method

Clears old "flash" data, marks the new one for deletion and handles "temp" data deletion.
protected _ci_init_vars ( ) : void
return void
    protected function _ci_init_vars()
    {
        if (!empty($_SESSION['__ci_vars'])) {
            $current_time = time();
            foreach ($_SESSION['__ci_vars'] as $key => &$value) {
                if ($value === 'new') {
                    $_SESSION['__ci_vars'][$key] = 'old';
                } elseif ($value < $current_time) {
                    unset($_SESSION[$key], $_SESSION['__ci_vars'][$key]);
                }
            }
            if (empty($_SESSION['__ci_vars'])) {
                unset($_SESSION['__ci_vars']);
            }
        }
        $this->userdata =& $_SESSION;
    }

Usage Example

示例#1
0
 protected function _ci_init_vars()
 {
     parent::_ci_init_vars();
     // An added feature: Keep all the flash data on AJAX requests.
     if (IS_AJAX_REQUEST) {
         $this->keep_flashdata();
     }
 }