homepage Welcome to WebmasterWorld Guest from 54.211.73.232
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / WebmasterWorld / Website Analytics - Tracking and Logging
Forum Library, Charter, Moderators: Receptional & mademetop

Website Analytics - Tracking and Logging Forum

    
Cookies On / Off - how to know - "now"?
Using PHP
Willis

10+ Year Member



 
Msg#: 2412 posted 7:31 am on Jun 17, 2004 (gmt 0)

The subject and description really sum it up but - I'm workin ona project that I need to know wether or not cookies are even turned on before I bother trying to run my script or if I merely report back a message saying "too bad".

Feedback?

 

PCInk

WebmasterWorld Senior Member 10+ Year Member



 
Msg#: 2412 posted 8:37 am on Jun 17, 2004 (gmt 0)

You need to set the cookie and then read it back to see it was set. Note that you can do this in JavaScript easily, in Perl/PHP/ASP, you need to set the cookie in one page and then redirect to another page to read it back as the browser only send the cookie data on each page request.

Willis

10+ Year Member



 
Msg#: 2412 posted 3:34 pm on Jun 17, 2004 (gmt 0)

Yes I reconize what you refer to with PHP cookiesets n requests.

So how do I use javascript for the task?
Would it work to set a cookie on javascript and then right after request it with PHP?

dcrombie

10+ Year Member



 
Msg#: 2412 posted 10:10 am on Jun 18, 2004 (gmt 0)

Using JavaScript:

A cookie can be set in the browser "immediately" and checked "immediately".
JavaScript functions are called AFTER a page request

Using PHP/ASP/...:

A cookie can be set AS the user request a page.
A cookie can be checked AS the user requests a SUBSEQUENT page.
PHP functions are called AS a page is requested, ie. BEFORE any JavaScript is run.

;)

TheDoctor

WebmasterWorld Senior Member 10+ Year Member



 
Msg#: 2412 posted 7:53 pm on Jun 18, 2004 (gmt 0)

Just a thought, and I've not tried it, but couldn't you set a cookie with php and try to read it with javascript, all on the same page?

dcrombie

10+ Year Member



 
Msg#: 2412 posted 12:50 pm on Jun 19, 2004 (gmt 0)

Yes you can, and it works, but if you're using JS to check the cookie wouldn't you use the same to set it?

;)

TheDoctor

WebmasterWorld Senior Member 10+ Year Member



 
Msg#: 2412 posted 1:03 pm on Jun 19, 2004 (gmt 0)

if you're using JS to check the cookie wouldn't you use the same to set it?

Ooh yes. You can tell I don't do this sort of thing very often :)

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / WebmasterWorld / Website Analytics - Tracking and Logging
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved