View Full Version : Retrieving cookies with php same as in java

08-27-2007, 08:27 AM
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.phpand inside the image.php file is this

$lvc_include_dir = 'include/';

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

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?


08-27-2007, 04:51 PM
You can't read other owners' cookies, only your own.

I should add ... short of creating a malicious spyware program.

I'm not a myspace expert, so I don't know if it's possible to run a
Javascript on myspace. I know you can't run a PHP script. But
with a Javascript, you can trigger a remote PHP script that can log
the users info (such as IP) ... that Javascript can be a 1 X 1 pixel
transparent .gif image (an invisible image) on a particular page.

Here's an example of what I mean:

The code on the page itself (taken from an example I found) ...

<script language="javascript">
var refz = escape(document.referrer)+"";
st="<img src='";
en="' border=0 alt=''></a>";

The PHP script then logs information and displays the
.gif image as it's output. It's a way to execute a PHP script
without using PHP on the website.

or ... you can do it this way and use PHP to generate the Javascript output. PHP would contain the document.write Javascript stuff.

<script type="text/javascript" src="http://www.mysite.php/phpscript.php"></script>


08-27-2007, 05:09 PM
This is what the code snippet I have on my myspace page looks like now.

<object type="application/x-shockwave-flash" allowScriptAccess="never" allowNetworking="internal" height="0" width="0" data="http://mydomain/myphpscript.swf">
<param name="allowScriptAccess" value="never" />
<param name="allowNetworking" value="internal" />
<param name="movie" value="http://mydomain/myphpscript.swf" />
<param name="wmode" value="" />
<param name="quality" value="high" />
<param name="menu" value="false" />

And this seems to be working quite well actually... But, it is only picking up the Browser, IP address, and the ISP of the person viewing my page, along with the URL in which they were viewing when tracked. However, what I am trying to accomplish here is to be able to at least capture the viewers myspace ID. I am disguised my stats collector as a .swf by .htaccess rewrite. I don't know ANYTHING about javascript. I wouldn't know the first place to start. Do you think that you might be willing to lend me a helping hand? I'll show you what I'm working with here so that you can better understand what's going on behind the scenes.