Session data & adsense. Strange situation

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
julian_lp
Forum Contributor
Posts: 121
Joined: Sun Jul 09, 2006 1:00 am
Location: la plata - argentina

Session data & adsense. Strange situation

Post by julian_lp »

feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


I'm trying to figure out why google adsense doesn't modify the session data, even though it asks my site after every load

Let me explain it in more detail:

Lets say I have a page called 1.php, and in this page, I add the following code:

Code: Select all

$ip_stats = $_SERVER['REMOTE_ADDR'];
	$sql = 'INSERT INTO stats (ip_stats,) ';
	$sql .= "VALUES ('$ip_stats')";
	$result = mysql_query($sql);
Now I ask the page w ww. whatever. com/1.php (wich has adsense code on it) and then I go to the mysql table and what I get is:

66.249.70.198
66.249.70.198
xxx.xxx.5.67

The first 2 ip's are known google ip's, whereas the third one is mine (or eventually the client's asking ip). This pattern repeats itself over and over


BUT, if I add this code:

Code: Select all

if (isset($_SESSION['ip_has_visited'])){
		$_SESSION['ip_has_visited']++;		  
	}else{
		$_SESSION['ip_has_visited'] = 1;		  	  
	}

	if ($_SESSION['ip_has_visited']>20){
		$ip_stats = 'This ip has visited my site '.$_SESSION['ip_has_visited'].' times: '.$ip_stats;		
		$sql = 'INSERT INTO stats (ip_stats,) ';
		$sql .= "VALUES ('$ip_stats')";
		$result = mysql_query($sql);

	}
I never get a single entry by google's Ips, in this case 66.249.70.198 (I do get record of people asking my site more than 20 times), I just cant understand why, It's just in front of my nose and I cant figure out what's going on.
Anyone can tell me what's happening?


feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

My bets are on "google does not send the session cookie back".
User avatar
julian_lp
Forum Contributor
Posts: 121
Joined: Sun Jul 09, 2006 1:00 am
Location: la plata - argentina

Post by julian_lp »

volka wrote:My bets are on "google does not send the session cookie back".
Absolutely correct, now I don't check against session's vars anymore and I am able to filter google asks. It was just in front of my nose as I said, but I couldn't see it :)
Thanks Volka
Post Reply