Help - Search - Members - Calendar
Full Version: setcookie - is this the correct way? Want to track visitors
Invision Power Services > Community Forums > Community Web Design and Coding
rakaposhi
Would appreciate some help with this php cookie thing: setcookie("name", "", time()+604800);
I just want to use cookies to track visitors. Would the above work, or do I have to somehow give a value? I will be reading the cookie using a logfile analyser.

Will this conflict with cookies set by IPB?
Dan C
QUOTE(rakaposhi @ Jul 10 2005, 03:17 PM) *
Would appreciate some help with this php cookie thing: setcookie("name", "", time()+604800);
I just want to use cookies to track visitors. Would the above work, or do I have to somehow give a value? I will be reading the cookie using a logfile analyser.

Will this conflict with cookies set by IPB?


The code you gave will simply create an empty cookie on the users system with the name 'name'. Whilst it won't conflict with IPB's cookies, it won't do anything of use.

You need to set the value for it to be of use to you. thumbsup.gif
rakaposhi
ok thx... I had a feeling thats what it was.. So how do I set a value? How do I give a value so that I can track it as a 'unique' visitor?
Dan C
Well, if you want to store the user's name, you are going to have to ask them to submit it to you... You can't just pluck their name out of nowhere, i'm afraid.
Kenny Pollock
Well, you could store the user's IP address, by placing $_SERVER['REMOTE_ADDR'] as the value of the cookie.
princetontiger
If it's the same name as an IPB cookie, then it could conflict. You should set the cookie properties of IPB to solely use your installed directory if you only want the IPB cookie to carry throughout the installed directory.
rakaposhi
QUOTE(Kenny Pollock @ Jul 10 2005, 07:07 PM) *
Well, you could store the user's IP address, by placing $_SERVER['REMOTE_ADDR'] as the value of the cookie.
but this won't help in visitor tracking... My webstats already uses IP's for defining uniques, but its no good when it comes to AOL etc...
QUOTE(2be1ask1 @ Jul 10 2005, 07:11 PM) *
If it's the same name as an IPB cookie, then it could conflict. You should set the cookie properties of IPB to solely use your installed directory if you only want the IPB cookie to carry throughout the installed directory.
I would want my cookie to work throughout the site, and not be excluded from the forums directory, which is what you seem to be implying...

this cookie business is turning out to be more of a damn headache than I anticipated devil.gif
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2009 Invision Power Services, Inc.