[Zope] sessions and disabled cookies

Charlie Reiman creiman@kefta.com
Fri, 27 Sep 2002 09:47:42 -0700


> Is there any way I can tell server side if the user is blocking
> my cookies?

Other than by their absence, nope. It would require two requests from the
server in controlled order. But you can detect it from javascript rather
easily which might help you.

var randstuff = Math.random().toString().substring(2);
document.cookie = "randstuff="+randstuff;
var accepts_cookies = (document.cookie.indexOf(randstuff)!=-1);
document.cookie = "randstuff=0; expires=Tue, 1-Jan-1980 02:02:02 GMT";

There is other code out there that assumes if document.cookie contains data
that cookies are accepted. I learned that with Moz 1.1 this is not true. You
need to perform an actual set-check test.

You could (this is gettin' scary here) then use more Javascript to modify
all links on a page to add whatever state data you desire. This is actually
pretty easy (see document.links) unless you've got frames in which case it
is only slightly challenging.

But as we all know, the Javascript road is paved with pain and suffering for
nothing more than pretty baubles.