Trying to set a cookie within a python script
Νίκος
nikos.the.gr33k at gmail.com
Sun Aug 1 12:56:48 EDT 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!
[code]
#!/usr/bin/python
# -*- 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
else
print ( "Απο δω και στο εξης δεν θα αυξανω τον μετρητη δικη σου
επισκεψη!!" )
cookie['visitor'] = ( 'nikos', time() + 60*60*24*365 ) #this
cookie will expire in an year
[/code]
More information about the Python-list
mailing list