PHP cookie into a string

cookies, php

Solution

Either of these may work depending on the complexity of your cookie array

implode(',',$_COOKIE)

json_encode($_COOKIE)

serialize($_COOKIE)

I'd advise against this, and just rely on traversing the array

simple example: $_COOKIE['name']

Problem

I read that in PHP, you can view all the cookies by using print_r, according to http://www.w3schools.com/php/php_cookies.asp . ``` <?php print_r($_COOKIE); ?> ``` But I want to do more with the content of the cookie. Is there a way to concatenate the cookie names and values into, something like a string variable, without knowing the cookie names, instead of relying on print_r? I couldn't find answers online. Thank you in advance.

Original source