Trying to set a cookie within a python script
Νίκος
nikos.the.gr33k at gmail.com
Tue Aug 3 02:03:18 EDT 2010
>On 2 Αύγ, 23:57, Thomas Jollans <thomas at jollans.com> wrote:
> So: tripple-check that
>
> * your file is <insert encoding here (aka UTF-8)>
> * Python knows that
> * the web browser knows that
Thank you! i used print ''' Content-Type: text/html; charset=UTF-8 /
n''' and it worked.
I'am still pretty confused about the encodings.
Please tell me the difference between 3 things.
a) Asking Notepad++(my editor) to save all my python scripts as UTF-8
without BOM.
b) Using this line '# -*- coding: utf-8 -*-' Isn't this line supposed
to tell browser that the contents of this python script as in UTF-8
and to handle it as such?
c) print ''' Content-Type: text/html; charset=UTF-8 /n'''
Please explain to me as simple as you can because from the time with
php and perl encodings not only gave me a hard time but also caused my
program to produce internal server errors so i need to understand the
differences.
=========================
Also in the other problem with the cookie iam trying to set:
=========================
if os.environ.get('HTTP_COOKIE') and cookie.has_key('visitor') ==
'nikos': #if visitor cookie exist
print "Next time i will count you"
cookie['visitor'] = ( 'nikos', time() - 1 ) #this cookie will expire
now
else:
print "I wont be counting you any more"
cookie['visitor'] = ( 'nikos', time() + 60*60*24*365 ) #this cookie
will expire in an year
=========================
Why always the code block pertainign to 'else' get exectuted ane never
the code of 'if'
The idea is who ever runs 'koukos.py' to set/unset himself out of the
counter count so i need i way to set/unset the browser cookie!
Thanks you!
More information about the Python-list
mailing list