Στις 27/10/2013 9:25 μμ, ο/η Benjamin Schollnick έγραψε:
Nikos,

Hello i having the following code to try and retrieve the visitor's
saved cookie form the browser.

[CODE]
# initialize cookie and retrieve cookie from clients browser try:
    cookie = cookies.SimpleCookie( os.environ['HTTP_COOKIE'] )
    cookieID = cookie['name'].value
except:
    cookieID = 'visitor'

*As it has been said before*, change the except to be an explicit error
check.
The all purpose except is hiding an error condition from you.

Take a look at this:

http://www.jayconrod.com/posts/17/how-to-use-http-cookies-in-python

- Benjamin



# initialize cookie and retrieve cookie from clients browser
cookie = cookies.SimpleCookie( os.environ.get('HTTP_COOKIE', '') )

try:
        cookieID = cookie['name'].value
except KeyError:
        cookieID = 'visitor'

As for the article i had found it myself 1 weeek ago read it but unfortunately it wasnt of any help.

--
What is now proved was at first only imagined! & WebHost
<http://superhost.gr>
--
https://mail.python.org/mailman/listinfo/python-list

Reply via email to