Is it possible to pull the cookies of a viewers browser when you are using a php script to track them on your site and return the info to a stats page, just as it would be done using javascript?

If it sounds like I don't know what I am talking about, it's because I don't. I am a novice at best. I am running a stats script on my server and using it to track the stats of individuals that view my site page that I have the code snippet on that returns the info back to my stats page. I have done this my embedding the url to the .swf file that pulls that stats in my sites page. Well, it's not an actual .swf file. I have the .htaccess file set like this

RewriteEngine on
RewriteRule image.swf image.php

and inside the image.php file is this

<?PHP
$lvc_include_dir = 'include/';

include($lvc_include_dir.'new-visitor.inc.php3');
?>

I am wondering if it is possible to retrieve the cookies as well using php scripting... Either the cookies of my site or of another site that are saved to the viewers computer...

Please let me know if this is at all possible..

~Chris

    You can retrieve cookies your site has set via the $_COOKIE super-global array.

      NogDog wrote:

      You can retrieve cookies your site has set via the $_COOKIE super-global array.

      Ok, so your saying that I can retrieve the cookies generated by the site that the individual is viewing? The site that has the code snippet inserted in it that pulls the stats, right?

      If it is possible to retrieve the cookies generated by the site the individual is currently viewing, then would it be at all possible to pull the same cookies if the individual were to view one of my other site that also has a stats snippet inserted into it as long as I know the cookie name that was created by one of my other sites that the individual has viewed?

        As far as I know, you can only read cookies from the current domain. Remember: your PHP script is not reading cookies from the files on the client computer, but rather receiving cookies that the client sends as part of the HTTP request/response traffic between it and the server. Besides, do you really want to be browsing on an internet where any server-side application could read cookies from any site you have visited?

        It might be possible to have a page on site A display an image or other object from site B that sets/reads a cookie, but many user's security settings will reject such 3rd-party cookies, so you can't count on that working.

          NogDog wrote:

          As far as I know, you can only read cookies from the current domain. Remember: your PHP script is not reading cookies from the files on the client computer, but rather receiving cookies that the client sends as part of the HTTP request/response traffic between it and the server. Besides, do you really want to be browsing on an internet where any server-side application could read cookies from any site you have visited?

          It might be possible to have a page on site A display an image or other object from site B that sets/reads a cookie, but many user's security settings will reject such 3rd-party cookies, so you can't count on that working.

          Ok, I guess that what I am really trying to get at here is this... I bought a domain several months back for the sole purpose of housing a statistics script, that does exactly that; it sends back information about the viewers of my various sites. This script itself is rather unconventional, as I have recently found other scripts that show much more information, such as phpMyVisites and Trace Watch, two wonderful open source stats scripts that I would suggest to anyone. However, I continue to use the original script that I had found, but only to capture the viewers IP address, which neither phpMyVisites nor Trace Watch do.

          So, moving along... The reason I have come to post this today is this; I have recently found that this php stats script that I have (the unconventional one) has proven to be pretty good for tracking the IP's, the ISP's, and the browsers of the people who view my myspace page... Yes yes I know, myspace!! What a joke, but I do have one. 😉 What I am trying to accomplish here is to be able to also return the viewers primary myspace photo, a URL to the viewers profile page, or maybe just the users myspace ID and I will handle the rest. But, at this point I would just like to be able to better know who each person is, rather than just having their IP address... I though that this might be done by retrieving the cookies that mayspace generates. Would you happen to have a better suggestion for me?

          ~Chris

            So you're trying to read cookies myspace.com has saved using a script on your own domain? In that case, the answer is no - that violates the security standards developed.

            The only thing you could probably do is use some Javascript on the MySpace page to read the cookie data and then make some sort of HTTP request back to your server with that information.

              Write a Reply...