CI_Session::flashdata PHP Method

flashdata() public method

Legacy CI_Session compatibility method
public flashdata ( string $key = NULL ) : mixed
$key string Session data key
return mixed Session data value or NULL if not found
    public function flashdata($key = NULL)
    {
        if (isset($key)) {
            return isset($_SESSION['__ci_vars'], $_SESSION['__ci_vars'][$key], $_SESSION[$key]) && !is_int($_SESSION['__ci_vars'][$key]) ? $_SESSION[$key] : NULL;
        }
        $flashdata = array();
        if (!empty($_SESSION['__ci_vars'])) {
            foreach ($_SESSION['__ci_vars'] as $key => &$value) {
                is_int($value) or $flashdata[$key] = $_SESSION[$key];
            }
        }
        return $flashdata;
    }

Usage Example

 public function index()
 {
     $this->load->view('layout/header');
     $error = $this->session->flashdata('message');
     $this->load->view('element/message', ['success' => $error]);
     $viewData = [];
     $response = $this->moneyzaurus->userData();
     if ($response['code'] == 200 && $response['data']['success']) {
         $viewData['data'] = $response['data']['data'];
     }
     $parent = false;
     $response = $this->moneyzaurus->connectionList($parent);
     if ($response['code'] == 200) {
         $viewData['connections_child'] = $response['data']['data'];
     }
     $parent = true;
     $response = $this->moneyzaurus->connectionList($parent);
     if ($response['code'] == 200) {
         $viewData['connections_parent'] = $response['data']['data'];
     }
     $this->load->view('page/profile', $viewData);
     $this->load->view('page/connections', $viewData);
     $this->load->view('page/logout', $viewData);
     $this->load->view('layout/footer');
 }
All Usage Examples Of CI_Session::flashdata