Cookie issue(cant fix it with anyhting)

N

Nick the Gr33k

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'

It works as expected except form the fact from when the visitor enters
my webpage(superhost.gr) by clicking a backlink of another webpage.

Then even if the cookie exists in his browser for some reason the try
fails and except take actions.

Can somebody explain why this is happening?

You can see this action yourself by hitting:

1. superhost.gr as a direct hit
2. by clicking superhost.gr's backlink from ypsilandio.gr/mythosweb.gr

You will see than in 2nd occasion another ebtry will appear in the
database here:

http://superhost.gr/?show=log&page=index.html
 
C

Chris Angelico

Can somebody explain why this is happening?

SONG--ERNEST [1]
Were I a king in very truth,
And had a son--a guileless youth--
In probable succession;
To teach him patience, teach him tact,
How promptly in a fix to act,
He should adopt, in point of fact,
A webmaster's profession.

Slow down. Stop panicking. You have posted this same question several
times, and each time you have not received a response because this is
NOT A PYTHON QUESTION. Pardon my raised voice, but I've just finished
a season of Princess Ida, where I'd call "HEADS UP UPSTAGE, BAR
MOVING!" from the fly tower down to the stage. You have been given
multiple avenues to explore, and you have not given any evidence that
you have explored them. Spend some time getting to know the
technologies you're trying to use. Buy a book if it helps. Take a
formal course, maybe. Whatever it takes, gain a bit of competence
before you try to make things work. At the moment, you're just poking
into a black box and hoping the right magic will happen, and then
panicking here to python-list whenever the wrong magic happens.

[1] http://math.boisestate.edu/gas/grand_duke/web_op/gd03.html

ChrisA
 
S

Steven D'Aprano

Can somebody explain why this is happening?

It is the same answer that you were told the last time you asked this
question, and the previous time you asked this question. And it will be
the same answer the next time you ask.
 
D

Denis McMahon

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'

It works as expected except form the fact from when the visitor enters
my webpage(superhost.gr) by clicking a backlink of another webpage.

Then even if the cookie exists in his browser for some reason the try
fails and except take actions.

Can somebody explain why this is happening?

You can see this action yourself by hitting:

1. superhost.gr as a direct hit 2. by clicking superhost.gr's backlink
from ypsilandio.gr/mythosweb.gr

You will see than in 2nd occasion another ebtry will appear in the
database here:

http://superhost.gr/?show=log&page=index.html

OK

I tried it. The counter in the database is incrementing (I think it's the
counter). There's only one entry in the table for my system.

I used the backlinks on each of the two pages above - the backlink on
mythosweb.gr I used twice.

So, whatever behaviour you're seeing is not what I'm seeing.
 
N

Nick the Gr33k

Στις 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'[/QUOTE][/QUOTE]

*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
[/QUOTE]

# 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.
 
N

Nick the Gr33k

Στις 27/10/2013 8:01 μμ, ο/η Denis McMahon έγÏαψε:
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'

It works as expected except form the fact from when the visitor enters
my webpage(superhost.gr) by clicking a backlink of another webpage.

Then even if the cookie exists in his browser for some reason the try
fails and except take actions.

Can somebody explain why this is happening?

You can see this action yourself by hitting:

1. superhost.gr as a direct hit 2. by clicking superhost.gr's backlink
from ypsilandio.gr/mythosweb.gr

You will see than in 2nd occasion another ebtry will appear in the
database here:

http://superhost.gr/?show=log&page=index.html

OK

I tried it. The counter in the database is incrementing (I think it's the
counter). There's only one entry in the table for my system.

I used the backlinks on each of the two pages above - the backlink on
mythosweb.gr I used twice.

So, whatever behaviour you're seeing is not what I'm seeing.


I have changed the code that why you dont see it.
I just couldnt resilve the cookie issues i was facing and decided to
track visitors just by their hostaname instead of a non working cookie.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,070
Latest member
BiogenixGummies

Latest Threads

Top