Forum OpenACS Q&A: Howto READ cookie and Know if Browser accepts without...

I am trying to determine if a user's browser accepts cookies.

In a tcl file I have:

ad_set_cookie -expires never "mycookie" "myvalue"

The above sets the cookie....
and in the same tcl file, I check

set my_cookie [ad_get_cookie "mycookie"]

if { [empty_string_p $my_cookie] } {
   # BROWSER Refuses Cookie
} else {
   # Browser ACCEPTS Cookie
}

This code always shows the cookie, even if the browser REFUSES the cookie. This is INCORRECT. The ad_get_cookie must be checking memory and not reading from the browser. (IE6 and Netscape7)

I can go to a different webpage and check the cookie find that indeed the cookie was not set....

How do I determine if a user's browser accepts a cookie WITHOUT going to a DIFFERENT webpage....

TIA
-Bob

I don't think you can, Cookies are sent as request headers by the browse.

This means that the only way to check if browser has accepted a cookie, is to check the request headers on an incoming request.

If you're setting the value of a Cookie and then checking the result of this value, you're not checking it in a request header.

I think the only way is to go to a different webpage...

Put an image on the page and check to see if the request for the image includes your cookie. That way you get a second request but the user does not have to navigate to another page.