How can I display cookies in codeigniter?

How can I show cookies?

I want to see cookies in codeigniter.

I see the session:

print_r($this->session->all_userdata());

But cookies?

+5
source share
2 answers

I looked at system/core/Input.php:

function _fetch_from_array(&$array, $index = '', $xss_clean = FALSE)
{
    if ( ! isset($array[$index]))
    {
        return FALSE;
    }

    if ($xss_clean === TRUE)
    {
        return $this->security->xss_clean($array[$index]);
    }

    return $array[$index];
}

function cookie($index = '', $xss_clean = FALSE)
{
    return $this->_fetch_from_array($_COOKIE, $index, $xss_clean);
}

As far as I can tell, you cannot show all cookies with $this->input->cookie(). Only one at a time.

If you really want to see all the cookies, just try it var_dump($_COOKIE).

Or, if you need to show only one cookie, specify your_key:$this->input->cookie('your_key')

Hope this helps =)

+2
source

Use $this->input->cookie().

For more options, use the cookie helper: http://codeigniter.com/user_guide/helpers/cookie_helper.html

+2
source

All Articles