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
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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.