Re: [PHP] Not counting my own page visits
On Mar 4, 2013, at 3:49 PM, David Robley wrote: > Misunderstanding what $cookie contains? It is a boolean, i.e. it will be > true or false depending on whether the cookie was set or not. To echo the > contents of a cookie, you need to use the cookie name, viz > > "; ?> You're right - I didn't really understand cookies. However, with everyone's help here, and by searching the web, I got it to work. Thank you to Tommy, Ash, and David! Angela -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Not counting my own page visits
On Mon, Mar 4, 2013 at 5:58 PM, Ashley Sheridan wrote: > On Tue, 2013-03-05 at 10:19 +1030, David Robley wrote: > >> Angela Barone wrote: >> >> > 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: >> > >> > > > $domain = ($_SERVER['HTTP_HOST'] != 'localhost') ? >> > $_SERVER['HTTP_HOST'] : false; >> > $cookie = setcookie('test2', '123' , time()+60*60*24*30, '/', $domain); >> > ?> >> > >> > >> > >> > >> > >> > Test Page >> > >> > >> > "; ?> >> > "; ?> >> > >> > >> > >> > 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 >> >> Misunderstanding what $cookie contains? It is a boolean, i.e. it will be >> true or false depending on whether the cookie was set or not. To echo the >> contents of a cookie, you need to use the cookie name, viz >> >> "; ?> >> >> -- >> Cheers >> David Robley >> >> Oxymoron: Sisterly Love. >> >> > > > Not just that, but if you set a cookie, you won't be able to retrieve it > in the same script I believe. It's only available in the $_COOKIES array > once you refresh the page, as that's when the super global is populated > from the cookie data that the browser sends. > > Thanks, > Ash > http://www.ashleysheridan.co.uk > > Same script *invocation*. The cookie gets set when the response is sent back to the client. If the client calls the same script again, that cookie then uploaded. :) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Not counting my own page visits
On Tue, 2013-03-05 at 10:19 +1030, David Robley wrote: > Angela Barone wrote: > > > 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: > > > > > $domain = ($_SERVER['HTTP_HOST'] != 'localhost') ? > > $_SERVER['HTTP_HOST'] : false; > > $cookie = setcookie('test2', '123' , time()+60*60*24*30, '/', $domain); > > ?> > > > > > > > > > > > > Test Page > > > > > > "; ?> > > "; ?> > > > > > > > > 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 > > Misunderstanding what $cookie contains? It is a boolean, i.e. it will be > true or false depending on whether the cookie was set or not. To echo the > contents of a cookie, you need to use the cookie name, viz > > "; ?> > > -- > Cheers > David Robley > > Oxymoron: Sisterly Love. > > Not just that, but if you set a cookie, you won't be able to retrieve it in the same script I believe. It's only available in the $_COOKIES array once you refresh the page, as that's when the super global is populated from the cookie data that the browser sends. Thanks, Ash http://www.ashleysheridan.co.uk
Re: [PHP] Not counting my own page visits
Angela Barone wrote: > 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: > > $domain = ($_SERVER['HTTP_HOST'] != 'localhost') ? > $_SERVER['HTTP_HOST'] : false; > $cookie = setcookie('test2', '123' , time()+60*60*24*30, '/', $domain); > ?> > > > > > > Test Page > > > "; ?> > "; ?> > > > > 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 Misunderstanding what $cookie contains? It is a boolean, i.e. it will be true or false depending on whether the cookie was set or not. To echo the contents of a cookie, you need to use the cookie name, viz "; ?> -- Cheers David Robley Oxymoron: Sisterly Love. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Not counting my own page visits
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: Test Page "; ?> "; ?> 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 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Not counting my own page visits
On Mon, 2013-03-04 at 10:15 -0800, Angela Barone wrote: > On Mar 4, 2013, at 9:56 AM, Ashley Sheridan wrote: > > set a cookie with a long life and check for that, discounting visits when > > either are true > > Hi Ash, > > I don't know anything about cookies. It sounds complicated to me. Is > there a simple way to set one? > > Thanks, > Angela 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. To test, visit the site with a different browser (browsers won't share the cookies) and you'll see the visit logged. Thanks, Ash http://www.ashleysheridan.co.uk
Re: [PHP] Not counting my own page visits
On Mar 4, 2013, at 9:56 AM, Ashley Sheridan wrote: > set a cookie with a long life and check for that, discounting visits when > either are true Hi Ash, I don't know anything about cookies. It sounds complicated to me. Is there a simple way to set one? Thanks, Angela -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Not counting my own page visits
On Mar 4, 2013, at 9:52 AM, Tommy Pham wrote: > What about ignoring $_SERVER['REMOTE_ADDR'] or $_SERVER['REMOTE_HOST'] > where that matches your public IP or FQDN? Hi Tommy, I am checking for $_SERVER['REMOTE_ADDR'] but how would I check that against mine? I don't have a static IP. Thanks, Angela -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Not counting my own page visits
Angela Barone wrote: >Hello, > > I have a script that counts hits to all the pages in my site and >emails me a report nightly. However, it also counts my visits to my >site, and when I'm coding, I'm hitting a lot of my pages, repeatedly. >I'd like to find a way to not count my page visits. > > At first, I thought about adding a parameter to each URL and parsing >that in the script, but that would get old real fast, and also, I may >forget to add it each time. Is there a way to tell the script to >ignore my visits? > >Thank you, >Angela >-- >PHP General Mailing List (http://www.php.net/) >To unsubscribe, visit: http://www.php.net/unsub.php You could do it by checking for your ip address if you have a fixed one, or set a cookie with a long life and check for that, discounting visits when either are true Thanks, Ash http://www.ashleysheridan.co.uk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Not counting my own page visits
On Mon, Mar 4, 2013 at 9:47 AM, Angela Barone wrote: > Hello, > > I have a script that counts hits to all the pages in my site and > emails me a report nightly. However, it also counts my visits to my site, > and when I'm coding, I'm hitting a lot of my pages, repeatedly. I'd like to > find a way to not count my page visits. > > At first, I thought about adding a parameter to each URL and parsing > that in the script, but that would get old real fast, and also, I may forget > to add it each time. Is there a way to tell the script to ignore my visits? > > Thank you, > Angela What about ignoring $_SERVER['REMOTE_ADDR'] or $_SERVER['REMOTE_HOST'] where that matches your public IP or FQDN? http://php.net/manual/en/reserved.variables.server.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Not counting my own page visits
Hello, I have a script that counts hits to all the pages in my site and emails me a report nightly. However, it also counts my visits to my site, and when I'm coding, I'm hitting a lot of my pages, repeatedly. I'd like to find a way to not count my page visits. At first, I thought about adding a parameter to each URL and parsing that in the script, but that would get old real fast, and also, I may forget to add it each time. Is there a way to tell the script to ignore my visits? Thank you, Angela -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php