Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #57760

Re: Cookie issue(cant fix it with anyhting)

From Benjamin Schollnick <benjamin@schollnick.net>
Subject Re: Cookie issue(cant fix it with anyhting)
Date 2013-10-27 15:25 -0400
References <l4gck0$mkj$1@dont-email.me> <l4jkd7$16b$3@dont-email.me>
Newsgroups comp.lang.python
Message-ID <mailman.1660.1382902405.18130.python-list@python.org> (permalink)

Show all headers | View raw


[Multipart message — attachments visible in raw view] - view raw

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


Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Cookie issue(cant fix it with anyhting) Nick the Gr33k <nikos.gr33k@gmail.com> - 2013-10-26 15:29 +0300
  Re: Cookie issue(cant fix it with anyhting) Chris Angelico <rosuav@gmail.com> - 2013-10-27 00:35 +1100
  Re: Cookie issue(cant fix it with anyhting) Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-10-26 15:48 +0000
  Re: Cookie issue(cant fix it with anyhting) Denis McMahon <denismfmcmahon@gmail.com> - 2013-10-27 18:01 +0000
    Re: Cookie issue(cant fix it with anyhting) Benjamin Schollnick <benjamin@schollnick.net> - 2013-10-27 15:25 -0400
      Re: Cookie issue(cant fix it with anyhting) Nick the Gr33k <nikos.gr33k@gmail.com> - 2013-10-27 23:17 +0200
    Re: Cookie issue(cant fix it with anyhting) Nick the Gr33k <nikos.gr33k@gmail.com> - 2013-10-27 23:19 +0200

csiph-web