Welcome to WebmasterWorld Guest from 54.146.201.80

Forum Moderators: DixonJones & mademetop

Message Too Old, No Replies

Cookies On / Off - how to know - "now"?

Using PHP

     
7:31 am on Jun 17, 2004 (gmt 0)

Junior Member

10+ Year Member

joined:Mar 4, 2004
posts:59
votes: 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?

8:37 am on June 17, 2004 (gmt 0)

Senior Member from GB 

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month

joined:Aug 13, 2003
posts:1028
votes: 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.
3:34 pm on June 17, 2004 (gmt 0)

Junior Member

10+ Year Member

joined:Mar 4, 2004
posts:59
votes: 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:10 am on June 18, 2004 (gmt 0)

Inactive Member
Account Expired

 
 


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.

;)

7:53 pm on June 18, 2004 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Feb 6, 2003
posts:661
votes: 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

12:50 pm on June 19, 2004 (gmt 0)

Inactive Member
Account Expired

 
 


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?

;)

1:03 pm on June 19, 2004 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Feb 6, 2003
posts:661
votes: 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 :)

 

Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members