views:

643

answers:

4

I guys.

Have worked around with cookies in PHP for some time. However something came to my mind.

Does its possible to gather all cookies (without knowing its names), or at least list all cookies names present in a browser?

Regards.

+4  A: 
print_r($_COOKIE)
porneL
Note that this only lists cookies for the server's domain, not all the cookies that the user has.
mgroves
Indeed. Fortunately (for users) it's not possible to read all cookies.
porneL
...because PHP doesn't "read"/pull the cookies, the browser sends them to the server.
VolkerK
+2  A: 

No, you can't. php can only locate cookies created from it self host. This security is from browser side.

lfx
+1  A: 

No, cookies are domain specific. You could get more protection against cookie hijacking by configuring your cookies as HttpOnly, supported in PHP since 5.2.0.

Jonas Elfström
I not familiarized with cookie jacking. LolBesides i never think about it until now.
Fábio Antunes
+2  A: 

Yes, you can get all the cookies that you have set by:

foreach($_COOKIE as $key => $value)
{
  echo $key . " => " . $value;
}

Hope this helps!

Gav
its the same asprint_r($_COOKIE);thks.
Fábio Antunes