Re: Not counting my own page visits

From: Date: Mon, 04 Mar 2013 23:09:41 +0000
Subject: Re: Not counting my own page visits
References: 1 2 3 4  Groups: php.general 
Request: Send a blank email to php-general+get-320399@lists.php.net to get a copy of this message
On Mar 4, 2013, at 11:33 AM, Ashley Sheridan wrote: > You can manually write a cookie on your machine, or use a special script that only you visit > that contains a setcookie() call (it only need be set once). From there on, you can check the > $_COOKIES super global for the presence of your cookie. I don't know why, but I can't get cookies to work. Here's a script I'm calling from my browser: <?php $domain = ($_SERVER['HTTP_HOST'] != 'localhost') ? $_SERVER['HTTP_HOST'] : false; $cookie = setcookie('test2', '123' , time()+60*60*24*30, '/', $domain); ?> <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8" /> <title>Test Page</title> </head> <body> <?php echo 'Cookie is: '.$_COOKIE[$cookie]."<br>"; ?> <?php echo 'Domain is: '.$domain."<br>"; ?> </body> </html> The domain is being displayed but the cookie is not. There's no cookie in the browser prefs, either. What am I doing wrong? Angela

« previous php.general (#320399) next »