Reputation: 5
I have worked on a little script which can be used to set cookies if you know the location. For example, this code below:
$(window).load(function () {
$('body').append('<iframe src="http://mydomain.com/setcookie?data=abc123" width="1" height="1" frameborder="0"></iframe>');
}); //sets cookie from desired location, you need its exact id/location.
Does anybody know any good method for taking a created cookie and then applying it to all visitors which visits (using this script), but not knowing the location?
I have thought of extracting the created cookie and then taking the information and creating my own php cookie, is this possible? tell me if I'm being unclear or something..
Upvotes: 0
Views: 140
Reputation: 24961
Try Jquery Cookie pluging: https://github.com/carhartl/jquery-cookie it will help you to create cookies in the client-side, you can then use standard PHP to read those cookies in the server-side.
[edit]
You can try to send to the server the URL from where the script was executed:
'<iframe src="http://mydomain.com/setcookie?data=abc123&location=' +
window.location.host + '"...
It should allow you to find where is it coming from, but it is not really secure as If I know a bit of coding I just need to find a trusted host and change for it window.location.host
you should better check the request in the server side ($_SERVER['HTTP_REFERER']).
Upvotes: 2