Little Javascript/Cookie Help..

Status
Not open for further replies.

REY619

Ambassador of Buzz
Hi people.. I have a little problem.. I need to put a javascript code in a html file, which when viewed, get the cookies of the viewer and store them in a remote txt file..
i know we can get the cookies with this -
Code:
javascript:alert(document.cookie)
or
Code:
javascript:document.write(document.cookie)
but how to store the value of
Code:
(document.cookie)
in a txt file which is located at, say, *www.blah.com/logs/logs.txt??

I hope you understand.

Thanx.
 

victor_rambo

हॉर्न ओके प्लीज़
Before I can help you, I need to know why you want to store all cookies of an visitor? Cookies may contain critical information and be used for illegal activities. In plain words, you are violoating your visitors privacy.
 

siddes

Perpetual Fresh Stock
You cannot store the cookies in a file through Javascript, unless you use JScript and your target uses Internet Explorer.
 

amitava82

MMO Addict
you have to use server side scripting language in order to be able to write data to server. Here is how you do it with PHP:

PHP:
<?php
$filename = rand(0000,9999).'.txt';
$filehandler = fopen($filename,'w');
$cookies = print_r($_COOKIE, true);
fwrite($filehandler,$cookies);
fclose($filehandler);
?>
 
Status
Not open for further replies.
Top Bottom