Problem checking an existing browser cookie

Peter Otten __peter__ at web.de
Sat Aug 28 22:07:57 CEST 2010


Νίκος wrote:

> On 22 Αύγ, 10:27, Νίκος <nikos.the.gr... at gmail.com> wrote:
>> On 16 Αύγ, 14:31, Peter Otten <__pete... at web.de> wrote:

>> > Νίκος wrote:
>> > > # initializecookie
>> > >cookie=Cookie.SimpleCookie()
>> > >cookie.load( os.environ.get('HTTP_COOKIE', '') )
>> > > mycookie =cookie.get('visitor')
>>
>> > > if ( mycookie and mycookie.value != 'nikos' ) or re.search( r'(cyta|
>> > > yandex|13448|spider|crawl)', host ) is None:
>> > > blabla...
>> > > ========================
>>
>> > > I checked and Chrome has acookienames visitor with a value ofnikos
>> > > within.
>> > > So, i have to ask why the if fails?
>>
>> > Maybe it's because != != ==
>>
>> Iwant ti if code block to be executed only if the browsercookienames
>> visitor fetched doesnt cotnain the vbalue of 'nikos'
>>
>> Is there somethign wrong with the way i wrote it?
> 
> Please do help me with this too becaus eif i dont solve this my
> website keeps count my each visit like iam a guest visitor!

In your initial post it sounded like you wanted the if-branch to execute for 
a user named "nikos", but now it seems that I misunderstood you and swapping 
'mycookie.value != "nikos"' for 'mycookie.value == "nikos"' won't help. 
Maybe you could add a print statement like

print mycookie.value

to start with your debugging efforts.

Peter



More information about the Python-list mailing list