import cgi,os,sys from snakeserver.snakelet import Snakelet import Cookie class TestCookie(Snakelet): sessionType=Snakelet.SESSION_NOT_NEEDED def serve(self, request, response): if request.arg!='check': # serve a cookie to the second stage (?check) # to check if cookies are enabled. response.setCookie("test","test-value") response.HTTPredirect(self.url+"?check") else: out = response.getOutput() cookies=Cookie.SimpleCookie(request.HTTP_COOKIE) print >>out, '' if not cookies.has_key("test"): # cookies are disabled! print >>out, """Cookies disabled

Cookies not enabled

You have disabled cookies in your browser (at least for this site). The site requires cookies to be enabled to work correctly.

Why cookies? The cookie is used to store your user identification, so we know who you are. The cookie is removed when you exit the browser. No personal information (password, user name) is stored in the cookie, only a unique identifier that we generate for you and use internally.

Solution: Please enable cookies for this site and try again.

This is an example text. The cookie-test has been done by a Snakelet.
""" % self.url return # we got the test cookie back, so cookies are enabled! print >>out, """Cookies enabled

Cookies enabled

You have enabled cookies in your browser (at least for this site). You can now proceed with the login procedure... etc.. etc..

Try to disable cookies now and refresh the page...

This is an example text. The cookie-test has been done by a Snakelet.
"""