Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #57600 > unrolled thread
| Started by | Nick the Gr33k <nikos.gr33k@gmail.com> |
|---|---|
| First post | 2013-10-26 15:29 +0300 |
| Last post | 2013-10-27 23:19 +0200 |
| Articles | 7 — 5 participants |
Back to article view | Back to comp.lang.python
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
| From | Nick the Gr33k <nikos.gr33k@gmail.com> |
|---|---|
| Date | 2013-10-26 15:29 +0300 |
| Subject | Cookie issue(cant fix it with anyhting) |
| Message-ID | <l4gck0$mkj$1@dont-email.me> |
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'
[/CODE]
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
[toc] | [next] | [standalone]
| From | Chris Angelico <rosuav@gmail.com> |
|---|---|
| Date | 2013-10-27 00:35 +1100 |
| Message-ID | <mailman.1575.1382794537.18130.python-list@python.org> |
| In reply to | #57600 |
On Sat, Oct 26, 2013 at 11:29 PM, Nick the Gr33k <nikos.gr33k@gmail.com> wrote:
> 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
[toc] | [prev] | [next] | [standalone]
| From | Steven D'Aprano <steve+comp.lang.python@pearwood.info> |
|---|---|
| Date | 2013-10-26 15:48 +0000 |
| Message-ID | <526be439$0$29972$c3e8da3$5496439d@news.astraweb.com> |
| In reply to | #57600 |
On Sat, 26 Oct 2013 15:29:52 +0300, Nick the Gr33k wrote: > 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. -- Steven
[toc] | [prev] | [next] | [standalone]
| From | Denis McMahon <denismfmcmahon@gmail.com> |
|---|---|
| Date | 2013-10-27 18:01 +0000 |
| Message-ID | <l4jkd7$16b$3@dont-email.me> |
| In reply to | #57600 |
On Sat, 26 Oct 2013 15:29:52 +0300, Nick the Gr33k wrote: > 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' > [/CODE] > > 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. -- Denis McMahon, denismfmcmahon@gmail.com
[toc] | [prev] | [next] | [standalone]
| From | Benjamin Schollnick <benjamin@schollnick.net> |
|---|---|
| Date | 2013-10-27 15:25 -0400 |
| Message-ID | <mailman.1660.1382902405.18130.python-list@python.org> |
| In reply to | #57755 |
[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
[toc] | [prev] | [next] | [standalone]
| From | Nick the Gr33k <nikos.gr33k@gmail.com> |
|---|---|
| Date | 2013-10-27 23:17 +0200 |
| Message-ID | <l4jvu3$jqq$1@dont-email.me> |
| In reply to | #57760 |
Στις 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>
[toc] | [prev] | [next] | [standalone]
| From | Nick the Gr33k <nikos.gr33k@gmail.com> |
|---|---|
| Date | 2013-10-27 23:19 +0200 |
| Message-ID | <l4k00e$jqq$2@dont-email.me> |
| In reply to | #57755 |
Στις 27/10/2013 8:01 μμ, ο/η Denis McMahon έγραψε: > On Sat, 26 Oct 2013 15:29:52 +0300, Nick the Gr33k wrote: > >> 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' >> [/CODE] >> >> 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. -- What is now proved was at first only imagined! & WebHost <http://superhost.gr>
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.python
csiph-web