Jump to content

show all cookies


lAZLf

Recommended Posts

I'm trying to show all the users cookies. So far I've tried:

echo $HTTP_GET_VARS["cookie"];

 

and

 

print_r($_COOKIE);

 

In the first one, I don't get anything return, in the second i get "Array ( )".

 

How do I do this? I want to write the user's cookies to a log. So in the long run I want it to be able to work in the fwrite() function.

Link to comment
https://forums.phpfreaks.com/topic/203373-show-all-cookies/
Share on other sites

Cookies are domain specific.

 

Also, depending on the subdomain/hostname and path settings in the cookie, cookies can also be specific to the subdomain/hostname and path where they were set.

 

Only valid cookies (that have not expired), that match the domain, and optionally match the subdomain/hostname and path of the URL that is being requested will be sent to the server with the http request.

Link to comment
https://forums.phpfreaks.com/topic/203373-show-all-cookies/#findComment-1065445
Share on other sites

My code:

<?php

if(!empty($_COOKIE)) {
$cookie = print_r($_COOKIE);
}
else {
$cookie = 'There are no Cookies, you must bake some.';
echo $cookie;
}

$date = date("I ds of F Y h:i:s A");
$user_agent = $_SERVER['HTTP_USER_AGENT'];

$file = fopen("log.txt", "a");
fwrite($file, "DATE : $date || USER AGENT : $user_agent || COOKIE : $cookie \n");
fclose($file);

?>

 

So far, it only works with Firefox, not safari. In firefox it prints the cookies, but it writes into the log file "... COOKIE : 1".

In safari it says that there are no cookies set, although there are.

 

Anybody know why it writes COOKIE : 1 in the file in firefox, and nothing in safari?

Link to comment
https://forums.phpfreaks.com/topic/203373-show-all-cookies/#findComment-1065452
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.