From: Νίκος on
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]
From: Steven D'Aprano on
On Sun, 01 Aug 2010 09:56:48 -0700, Νίκος wrote:

> Hello fellow Python Coders!
>
> I don't see the error in my attempt to set a a cookie in this test
> script.

Neither do I. What makes you think there is an error? What sort of error?
Do you get a core dump, an exception, or something else?

Please report what you get, and what you expect, and how they are
different.


--
Steven
From: Νίκος on
>On 2 Αύγ, 03:52, Steven D'Aprano <steve-REMOVE-T...(a)cybersource.com.au> wrote:

> Neither do I. What makes you think there is an error? What sort of error?
> Do you get a core dump, an exception, or something else?
>
> Please report what you get, and what you expect, and how they are
> different.

Hello Steven,

Here is the script when it tries to run from my remote web server:
http://www.webville.gr/cgi-bin/koukos.py

Its seems the error is in this line of code, somwthing with time.

19 cookie['visitor'] = ( 'nikos', time() +
60*60*24*365 ) #this cookie will expire in an year

From: Νίκος on
Also my greek print appear in funny encoding although i do use # -*-
coding: utf-8 -*-
From: MRAB on
Νίκος wrote:
> Also my greek print appear in funny encoding although i do use # -*-
> coding: utf-8 -*-

That line just tells Python what encoding the source file itself uses.
It doesn't affect what the program does or how it runs.