PHP cookie in line

I read that in PHP you can view all cookies with print_r, according to http://www.w3schools.com/php/php_cookies.asp .

<?php 
  print_r($_COOKIE); 
?>

But I want to do more with the contents of the cookie.

Is there a way to associate cookie names and values ​​with something like a string variable without knowing the cookie names, instead of relying on print_r?

I could not find the answers on the Internet. Thanks in advance.

+3
source share
3 answers

Any of these may work depending on the complexity of your cookie array.

implode(',',$_COOKIE)

json_encode($_COOKIE)

serialize($_COOKIE)

I would advise against this and just rely on moving the array

simple example: $ _COOKIE ['name']

+6
source

coookie, , :

foreach ($_COOKIE as $name => $value) {
   print "Variable " . $name . " has value " . $value . "<br />\n";
}
+3

debuggin, _POST, _GET, _SESSION, _COOKIE

 echo "<pre>";
foreach ($_COOKIE as $key => $val) {
    echo "[$key] = $val \r\n";
    if(is_array($val)) {
        echo "is ARRAY ::::::: \"$key\" : \r\n";
        foreach ($val as $key2 => $val2) {
            echo "[$key2] = $val2 \r\n";
        }
    }
}
echo "</pre>";  
0

All Articles