Trying to set a cookie within a python script

Νίκος nikos.the.gr33k at
Sun Aug 1 18:56:48 CEST 2010

Hello fellow Python Coders!

I don't see the error in my attempt to set a a cookie in this test
script. Can you help please?! Thank you!

# -*- coding: utf-8 -*-

import Cookie

print ( "Content-type: text/html\n" )

cookie = Cookie.SimpleCookie()

if cookie.has_key('visitor') == "nikos"      #if visitor cookie exist
   print ( "Δεν σε ειδα, δεν σε ξερω, δεν σε ακουσα. Θα εισαι ο
αοραστος επισκεπτης!!" )
   cookie['visitor'] = ( 'nikos', time() - 1 )      #this cookie will
expire now
   print ( "Απο δω και στο εξης δεν θα αυξανω τον μετρητη δικη σου
επισκεψη!!" )
   cookie['visitor'] = ( 'nikos', time() + 60*60*24*365 )      #this
cookie will expire in an year

More information about the Python-list mailing list