Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #56380 > unrolled thread
| Started by | Νίκος Αλεξόπουλος <nikos.gr33k@gmail.com> |
|---|---|
| First post | 2013-10-08 13:04 +0300 |
| Last post | 2013-10-09 01:24 +0000 |
| Articles | 20 on this page of 52 — 17 participants |
Back to article view | Back to comp.lang.python
Cookie gets changed when hit comes from a referrer Νίκος Αλεξόπουλος <nikos.gr33k@gmail.com> - 2013-10-08 13:04 +0300
Re: Cookie gets changed when hit comes from a referrer Ian Kelly <ian.g.kelly@gmail.com> - 2013-10-08 05:08 -0600
Re: Cookie gets changed when hit comes from a referrer Νίκος Αλεξόπουλος <nikos.gr33k@gmail.com> - 2013-10-08 17:18 +0300
Re: Cookie gets changed when hit comes from a referrer Ian Kelly <ian.g.kelly@gmail.com> - 2013-10-08 22:53 -0600
Re: Cookie gets changed when hit comes from a referrer Νίκος Αλεξόπουλος <nikos.gr33k@gmail.com> - 2013-10-09 09:47 +0300
Re: Cookie gets changed when hit comes from a referrer Ben Finney <ben+python@benfinney.id.au> - 2013-10-09 18:12 +1100
Re: Cookie gets changed when hit comes from a referrer Νίκος Αλεξόπουλος <nikos.gr33k@gmail.com> - 2013-10-08 17:36 +0300
Re: Cookie gets changed when hit comes from a referrer Denis McMahon <denismfmcmahon@gmail.com> - 2013-10-08 15:55 +0000
Re: Cookie gets changed when hit comes from a referrer Νίκος Αλεξόπουλος <nikos.gr33k@gmail.com> - 2013-10-08 19:04 +0300
Re: Cookie gets changed when hit comes from a referrer Joel Goldstick <joel.goldstick@gmail.com> - 2013-10-08 13:10 -0400
Re: Cookie gets changed when hit comes from a referrer Denis McMahon <denismfmcmahon@gmail.com> - 2013-10-08 19:29 +0000
Re: Cookie gets changed when hit comes from a referrer Νίκος Αλεξόπουλος <nikos.gr33k@gmail.com> - 2013-10-09 01:52 +0300
Re: Cookie gets changed when hit comes from a referrer Ned Batchelder <ned@nedbatchelder.com> - 2013-10-08 19:57 -0400
Re: Cookie gets changed when hit comes from a referrer Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-10-09 01:33 +0000
Re: Cookie gets changed when hit comes from a referrer Νίκος Αλεξόπουλος <nikos.gr33k@gmail.com> - 2013-10-09 11:24 +0300
Re: Cookie gets changed when hit comes from a referrer Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-10-09 09:44 +0100
Re: Cookie gets changed when hit comes from a referrer Denis McMahon <denismfmcmahon@gmail.com> - 2013-10-09 14:45 +0000
Re: Cookie gets changed when hit comes from a referrer Piet van Oostrum <piet@vanoostrum.org> - 2013-10-09 14:36 -0400
Re: Cookie gets changed when hit comes from a referrer Νίκος Αλεξόπουλος <nikos.gr33k@gmail.com> - 2013-10-10 00:29 +0300
Re: Cookie gets changed when hit comes from a referrer Joel Goldstick <joel.goldstick@gmail.com> - 2013-10-09 18:03 -0400
Re: Cookie gets changed when hit comes from a referrer Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-10-09 23:26 +0100
Re: Cookie gets changed when hit comes from a referrer Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-10-09 08:00 +0100
Re: Cookie gets changed when hit comes from a referrer Denis McMahon <denismfmcmahon@gmail.com> - 2013-10-09 14:43 +0000
Re: Cookie gets changed when hit comes from a referrer Νίκος Αλεξόπουλος <nikos.gr33k@gmail.com> - 2013-10-09 18:00 +0300
Re: Cookie gets changed when hit comes from a referrer Joel Goldstick <joel.goldstick@gmail.com> - 2013-10-09 11:20 -0400
Re: Cookie gets changed when hit comes from a referrer Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-10-09 16:39 +0100
Re: Cookie gets changed when hit comes from a referrer Denis McMahon <denismfmcmahon@gmail.com> - 2013-10-09 18:06 +0000
Re: Cookie gets changed when hit comes from a referrer Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-10-09 19:28 +0100
Re: Cookie gets changed when hit comes from a referrer Tim Chase <python.list@tim.thechases.com> - 2013-10-09 14:26 -0500
Re: Cookie gets changed when hit comes from a referrer Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-10-09 20:40 +0100
Re: Cookie gets changed when hit comes from a referrer Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-10-09 23:48 +0000
Re: Cookie gets changed when hit comes from a referrer Chris Angelico <rosuav@gmail.com> - 2013-10-10 11:18 +1100
Re: Cookie gets changed when hit comes from a referrer Denis McMahon <denismfmcmahon@gmail.com> - 2013-10-10 00:31 +0000
Re: Cookie gets changed when hit comes from a referrer Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-10-10 01:10 +0000
Re: Cookie gets changed when hit comes from a referrer Chris Angelico <rosuav@gmail.com> - 2013-10-10 12:28 +1100
Re: Cookie gets changed when hit comes from a referrer Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-10-10 06:21 +0100
Re: Cookie gets changed when hit comes from a referrer rusi <rustompmody@gmail.com> - 2013-10-09 22:36 -0700
Re: Cookie gets changed when hit comes from a referrer Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-10-10 06:56 +0100
Re: Cookie gets changed when hit comes from a referrer Ben Finney <ben+python@benfinney.id.au> - 2013-10-10 17:01 +1100
Re: Cookie gets changed when hit comes from a referrer Steven D'Aprano <steve@pearwood.info> - 2013-10-10 07:20 +0000
Re: Cookie gets changed when hit comes from a referrer Steven D'Aprano <steve@pearwood.info> - 2013-10-10 07:18 +0000
Re: Cookie gets changed when hit comes from a referrer Antoon Pardon <antoon.pardon@rece.vub.ac.be> - 2013-10-10 10:50 +0200
Re: Cookie gets changed when hit comes from a referrer Denis McMahon <denismfmcmahon@gmail.com> - 2013-10-10 13:42 +0000
Re: Cookie gets changed when hit comes from a referrer Ben Finney <ben+python@benfinney.id.au> - 2013-10-10 11:43 +1100
Re: Cookie gets changed when hit comes from a referrer Roy Smith <roy@panix.com> - 2013-10-09 20:58 -0400
Learning about HTTP [was: Cookie gets changed when hit comes from a referrer] Tim Golden <mail@timgolden.me.uk> - 2013-10-10 08:44 +0100
Re: Cookie gets changed when hit comes from a referrer Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2013-10-10 19:45 -0400
Re: Cookie gets changed when hit comes from a referrer Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2013-10-10 19:48 -0400
Re: Cookie gets changed when hit comes from a referrer Denis McMahon <denismfmcmahon@gmail.com> - 2013-10-09 18:06 +0000
Re: Cookie gets changed when hit comes from a referrer Νίκος Αλεξόπουλος <nikos.gr33k@gmail.com> - 2013-10-08 20:30 +0300
Re: Cookie gets changed when hit comes from a referrer Joel Goldstick <joel.goldstick@gmail.com> - 2013-10-08 13:47 -0400
Re: Cookie gets changed when hit comes from a referrer Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-10-09 01:24 +0000
Page 1 of 3 [1] 2 3 Next page →
| From | Νίκος Αλεξόπουλος <nikos.gr33k@gmail.com> |
|---|---|
| Date | 2013-10-08 13:04 +0300 |
| Subject | Cookie gets changed when hit comes from a referrer |
| Message-ID | <l30lbg$etp$1@dont-email.me> |
# initialize cookie and retrieve cookie from clients browser
cookie = cookies.SimpleCookie( os.environ.get('HTTP_COOKIE') )
if cookie.get('ID') is not None:
cookieID = cookie['ID'].value
else:
cookieID = random.randrange(0, 9999)
cookie['ID'] = cookieID
cookie['ID']['path'] = '/'
print( cookie )
===========
===========
I use this code to retrive or set a cookie to the visitor's browser if
present and identify him bu it.
All work well except the situation where the user visits my webpage by
clicking a backlink on another wbpage.
Then for some reason the cookieID changes to another value thus a new
entry appears into the database when insert happens.
What cna i do about that?
[toc] | [next] | [standalone]
| From | Ian Kelly <ian.g.kelly@gmail.com> |
|---|---|
| Date | 2013-10-08 05:08 -0600 |
| Message-ID | <mailman.850.1381230535.18130.python-list@python.org> |
| In reply to | #56380 |
On Tue, Oct 8, 2013 at 4:04 AM, Νίκος Αλεξόπουλος <nikos.gr33k@gmail.com> wrote: > I use this code to retrive or set a cookie to the visitor's browser if > present and identify him bu it. > > All work well except the situation where the user visits my webpage by > clicking a backlink on another wbpage. > > Then for some reason the cookieID changes to another value thus a new entry > appears into the database when insert happens. > > What cna i do about that? This question is really about HTTP, not Python, so you'd have better luck asking elsewhere. The most likely possibility is that the domain doesn't match. For example, the cookie is set for the domain www.foo.com, and the other webpage is linking to foo.com. Another possibility is that the cookie is expiring because the browser session was terminated, not because of anything to do with the other webpage. Or it could simply be a bug or unusual setting in whatever browser you're using to test it.
[toc] | [prev] | [next] | [standalone]
| From | Νίκος Αλεξόπουλος <nikos.gr33k@gmail.com> |
|---|---|
| Date | 2013-10-08 17:18 +0300 |
| Message-ID | <l31472$56i$1@dont-email.me> |
| In reply to | #56387 |
Στις 8/10/2013 2:08 μμ, ο/η Ian Kelly έγραψε: > On Tue, Oct 8, 2013 at 4:04 AM, Νίκος Αλεξόπουλος <nikos.gr33k@gmail.com> wrote: >> I use this code to retrive or set a cookie to the visitor's browser if >> present and identify him bu it. >> >> All work well except the situation where the user visits my webpage by >> clicking a backlink on another wbpage. >> >> Then for some reason the cookieID changes to another value thus a new entry >> appears into the database when insert happens. >> >> What cna i do about that? > > This question is really about HTTP, not Python, so you'd have better > luck asking elsewhere. The most likely possibility is that the domain > doesn't match. For example, the cookie is set for the domain > www.foo.com, and the other webpage is linking to foo.com. Another > possibility is that the cookie is expiring because the browser session > was terminated, not because of anything to do with the other webpage. > Or it could simply be a bug or unusual setting in whatever browser > you're using to test it. > When i direct hit http://superhost.gr the cookie remains the same it is not lost. Also i have set: ookie['ID']['expires'] = 60*60*24*365 #this cookie will expire in a year but that didnt also help much because the cookie is also changing when the hit comes through a referrer. So, i cannot se the cookie down to its feet my whole insert or update procedure breaks and i have duplicate entried for the same hostnames. Where shoudl i rely to identify a visitor? I was relying on tis hostname(although i know that after a router reset) it changes, and then couple days ago i was thiking of relying to a cookie that i would/set retrive from the vistirs browser, but if it changes all the time i cannot evan rely to that. -- What is now proved was at first only imagined! & WebHost <http://superhost.gr>
[toc] | [prev] | [next] | [standalone]
| From | Ian Kelly <ian.g.kelly@gmail.com> |
|---|---|
| Date | 2013-10-08 22:53 -0600 |
| Message-ID | <mailman.886.1381294482.18130.python-list@python.org> |
| In reply to | #56401 |
On Tue, Oct 8, 2013 at 8:18 AM, Νίκος Αλεξόπουλος <nikos.gr33k@gmail.com> wrote: > Also i have set: > ookie['ID']['expires'] = 60*60*24*365 #this cookie will expire in > a year The Expires attribute takes a date. If you're passing an interval in seconds then you should use the Max-Age attribute instead. That said, I think I misunderstood the problem initially. You are saying that when the user is on another site, and they press the browser's Back button to return to your page, your host is not recording a visit from the cookie you've given them? This is probably happening because the browser is not actually sending a request to your web server when it navigates back, unless the user specifically requests a refresh. Otherwise, most browsers will just use the cached page already in memory in this situation. As far as the server is concerned, nothing has happened.
[toc] | [prev] | [next] | [standalone]
| From | Νίκος Αλεξόπουλος <nikos.gr33k@gmail.com> |
|---|---|
| Date | 2013-10-09 09:47 +0300 |
| Message-ID | <l32u5u$icj$1@dont-email.me> |
| In reply to | #56464 |
Στις 9/10/2013 7:53 πμ, ο/η Ian Kelly έγραψε: > On Tue, Oct 8, 2013 at 8:18 AM, Νίκος Αλεξόπουλος <nikos.gr33k@gmail.com> wrote: >> Also i have set: >> ookie['ID']['expires'] = 60*60*24*365 #this cookie will expire in >> a year > > The Expires attribute takes a date. If you're passing an interval in > seconds then you should use the Max-Age attribute instead. > > That said, I think I misunderstood the problem initially. You are > saying that when the user is on another site, and they press the > browser's Back button to return to your page, your host is not > recording a visit from the cookie you've given them? This is probably > happening because the browser is not actually sending a request to > your web server when it navigates back, unless the user specifically > requests a refresh. Otherwise, most browsers will just use the cached > page already in memory in this situation. As far as the server is > concerned, nothing has happened. > No i dont mean that. When a user hits my link on another website, for exmaple they are on ypsilandio.gr and they hit the link of superhost.gr then a new entry with a new cookie is appearing into my visitors table! Where is the old cookie that was saved in my browser so it will get retrieved? I use chrome and i notice that when a visitor comes to my webpage form a referrer link the cookie's ID is always set to a new random value. I have no idea why. Why would it metter from where you sre coming from? The cookie ust have beeen present in the visitor's browser, shouldnt it? -- What is now proved was at first only imagined! & WebHost <http://superhost.gr>
[toc] | [prev] | [next] | [standalone]
| From | Ben Finney <ben+python@benfinney.id.au> |
|---|---|
| Date | 2013-10-09 18:12 +1100 |
| Message-ID | <mailman.889.1381302753.18130.python-list@python.org> |
| In reply to | #56473 |
Νίκος Αλεξόπουλος <nikos.gr33k@gmail.com> writes: > When a user hits my link on another website, for exmaple they are on > ypsilandio.gr and they hit the link of superhost.gr then a new entry > with a new cookie is appearing into my visitors table! > > Where is the old cookie that was saved in my browser so it will get > retrieved? I use chrome and i notice that when a visitor comes to my > webpage form a referrer link the cookie's ID is always set to a new > random value. None of this has to do with Python. Please do not ask this Python doscussion forum to educate you on how HTTP operates. -- \ “How many people here have telekenetic powers? Raise my hand.” | `\ —Emo Philips | _o__) | Ben Finney
[toc] | [prev] | [next] | [standalone]
| From | Νίκος Αλεξόπουλος <nikos.gr33k@gmail.com> |
|---|---|
| Date | 2013-10-08 17:36 +0300 |
| Message-ID | <l315a0$a55$1@dont-email.me> |
| In reply to | #56387 |
Στις 8/10/2013 2:08 μμ, ο/η Ian Kelly έγραψε: > This question is really about HTTP, not Python, so you'd have better > luck asking elsewhere. The most likely possibility is that the domain > doesn't match. For example, the cookie is set for the domain > www.foo.com, and the other webpage is linking to foo.com. I think this is the problem but iam not sure entirely how you mean. Can you please explain it a bit more? Shall i change cookie['ID']['path'] = '/' to something else so that never happens? -- What is now proved was at first only imagined! & WebHost <http://superhost.gr>
[toc] | [prev] | [next] | [standalone]
| From | Denis McMahon <denismfmcmahon@gmail.com> |
|---|---|
| Date | 2013-10-08 15:55 +0000 |
| Message-ID | <l319sl$cl6$3@dont-email.me> |
| In reply to | #56380 |
On Tue, 08 Oct 2013 13:04:34 +0300, Νίκος Αλεξόπουλος wrote: > I use this code to retrive or set a cookie to the visitor's browser if > present and identify him bu it. You are aware that using cookies to track a user who doesn't want to be tracked won't work, because he'll just tell his browser to not use cookies, aren't you. Nick, if a user doesn't want to be tracked, you can't track them. The user controls all the data their machine sends to you. This means that they can manipulate it. Nothing you can do will prevent this. -- Denis McMahon, denismfmcmahon@gmail.com
[toc] | [prev] | [next] | [standalone]
| From | Νίκος Αλεξόπουλος <nikos.gr33k@gmail.com> |
|---|---|
| Date | 2013-10-08 19:04 +0300 |
| Message-ID | <l31aek$dd5$1@dont-email.me> |
| In reply to | #56423 |
Στις 8/10/2013 6:55 μμ, ο/η Denis McMahon έγραψε: > On Tue, 08 Oct 2013 13:04:34 +0300, Νίκος Αλεξόπουλος wrote: > >> I use this code to retrive or set a cookie to the visitor's browser if >> present and identify him bu it. > > You are aware that using cookies to track a user who doesn't want to be > tracked won't work, because he'll just tell his browser to not use > cookies, aren't you. > > Nick, if a user doesn't want to be tracked, you can't track them. The > user controls all the data their machine sends to you. This means that > they can manipulate it. Nothing you can do will prevent this. > Yes iam aware of that, but its the best trcking method i can think of. Tracking just the hostname is not accurate since with every router restart, that info is changing. Tracking the visitor by settign a cookie to its browser is not perfect/accurate since he can manipulate its broswer data or flush the cookies but this is the best one can do after having people register on the webiste. Or perhaps trying to identify the cookie + hostname is even better. Can you help me with this particuler problem please? -- What is now proved was at first only imagined! & WebHost <http://superhost.gr>
[toc] | [prev] | [next] | [standalone]
| From | Joel Goldstick <joel.goldstick@gmail.com> |
|---|---|
| Date | 2013-10-08 13:10 -0400 |
| Message-ID | <mailman.871.1381256741.18130.python-list@python.org> |
| In reply to | #56426 |
On Tue, Oct 8, 2013 at 12:04 PM, Νίκος Αλεξόπουλος <nikos.gr33k@gmail.com> wrote: > Στις 8/10/2013 6:55 μμ, ο/η Denis McMahon έγραψε: > >> On Tue, 08 Oct 2013 13:04:34 +0300, Νίκος Αλεξόπουλος wrote: >> >>> I use this code to retrive or set a cookie to the visitor's browser if >>> present and identify him bu it. >> >> Browser cookies have been defined and around for a very long time. If you google "browser cookie tutorial" you can learn how they work -- probably within an hour!. This will help you find your solution The first poster pointed out that www.example.com and example.com can be considered different domains. You can make a cookie work for both but you need to understand cookies to learn how. This is off topic, ... again! > https://mail.python.org/mailman/listinfo/python-list -- Joel Goldstick http://joelgoldstick.com
[toc] | [prev] | [next] | [standalone]
| From | Denis McMahon <denismfmcmahon@gmail.com> |
|---|---|
| Date | 2013-10-08 19:29 +0000 |
| Message-ID | <l31mf8$cl6$4@dont-email.me> |
| In reply to | #56426 |
On Tue, 08 Oct 2013 19:04:37 +0300, Νίκος Αλεξόπουλος wrote: > Can you help me with this particuler problem please? Unfortunately I can't, because I am unable to reproduce the problem you describe. When I load my test page in the browser, then replace it with something else by entering an address in the address bar and pressing return, then use the back link followed by the reload one, I am back at my test page with the original cookie value. Of course, this is using my cookie etc code and mechanisms, and not yours .... Now, either it's an issue in your python implementation of cookie handling which isn't happening in my implementation, or it's something to do with the way that your system passes data around (cgi) that doesn't happen in mine (mod_wsgi), or it's happening in the browser you're testing in, but not in my browser. Have you checked the cookie jar in the browser to see what value the cookie has? Is that the value you think it should have? Note that checking the cookie jar is a browser topic, not a python topic, so if you don't know how to do that you're going to have to find the right place to ask, WHICH IS NOT HERE! Ideally you need to check what the server thinks it's setting the cooking to, what the browser thinks it received as the cookie, and what the server gets back afterwards to work out where the error is happening. -- Denis McMahon, denismfmcmahon@gmail.com
[toc] | [prev] | [next] | [standalone]
| From | Νίκος Αλεξόπουλος <nikos.gr33k@gmail.com> |
|---|---|
| Date | 2013-10-09 01:52 +0300 |
| Message-ID | <l322bq$1ll$1@dont-email.me> |
| In reply to | #56440 |
Στις 8/10/2013 10:29 μμ, ο/η Denis McMahon έγραψε: > On Tue, 08 Oct 2013 19:04:37 +0300, Νίκος Αλεξόπουλος wrote: > >> Can you help me with this particuler problem please? > > Unfortunately I can't, because I am unable to reproduce the problem you > describe. > > When I load my test page in the browser, then replace it with something > else by entering an address in the address bar and pressing return, then > use the back link followed by the reload one, I am back at my test page > with the original cookie value. > > Of course, this is using my cookie etc code and mechanisms, and not > yours .... > > Now, either it's an issue in your python implementation of cookie > handling which isn't happening in my implementation, or it's something to > do with the way that your system passes data around (cgi) that doesn't > happen in mine (mod_wsgi), or it's happening in the browser you're > testing in, but not in my browser. > > Have you checked the cookie jar in the browser to see what value the > cookie has? Is that the value you think it should have? Note that > checking the cookie jar is a browser topic, not a python topic, so if you > don't know how to do that you're going to have to find the right place to > ask, WHICH IS NOT HERE! > > Ideally you need to check what the server thinks it's setting the cooking > to, what the browser thinks it received as the cookie, and what the > server gets back afterwards to work out where the error is happening. Is there something i can try to isolate the problem and make it work? By whole counters project is based on cookie handling now.... -- What is now proved was at first only imagined! & WebHost <http://superhost.gr>
[toc] | [prev] | [next] | [standalone]
| From | Ned Batchelder <ned@nedbatchelder.com> |
|---|---|
| Date | 2013-10-08 19:57 -0400 |
| Message-ID | <mailman.881.1381276656.18130.python-list@python.org> |
| In reply to | #56452 |
On 10/8/13 6:52 PM, Νίκος Αλεξόπουλος wrote: > Στις 8/10/2013 10:29 μμ, ο/η Denis McMahon έγραψε: >> On Tue, 08 Oct 2013 19:04:37 +0300, Νίκος Αλεξόπουλος wrote: >> >>> Can you help me with this particuler problem please? >> >> Unfortunately I can't, because I am unable to reproduce the problem you >> describe. >> >> When I load my test page in the browser, then replace it with something >> else by entering an address in the address bar and pressing return, then >> use the back link followed by the reload one, I am back at my test page >> with the original cookie value. >> >> Of course, this is using my cookie etc code and mechanisms, and not >> yours .... >> >> Now, either it's an issue in your python implementation of cookie >> handling which isn't happening in my implementation, or it's >> something to >> do with the way that your system passes data around (cgi) that doesn't >> happen in mine (mod_wsgi), or it's happening in the browser you're >> testing in, but not in my browser. >> >> Have you checked the cookie jar in the browser to see what value the >> cookie has? Is that the value you think it should have? Note that >> checking the cookie jar is a browser topic, not a python topic, so if >> you >> don't know how to do that you're going to have to find the right >> place to >> ask, WHICH IS NOT HERE! >> >> Ideally you need to check what the server thinks it's setting the >> cooking >> to, what the browser thinks it received as the cookie, and what the >> server gets back afterwards to work out where the error is happening. > > Is there something i can try to isolate the problem and make it work? > By whole counters project is based on cookie handling now.... > > Nikos, as a few people have mentioned already, this is no longer a Python question. You need to find other avenues of support. --Ned.
[toc] | [prev] | [next] | [standalone]
| From | Steven D'Aprano <steve+comp.lang.python@pearwood.info> |
|---|---|
| Date | 2013-10-09 01:33 +0000 |
| Message-ID | <5254b264$0$29984$c3e8da3$5496439d@news.astraweb.com> |
| In reply to | #56452 |
On Wed, 09 Oct 2013 01:52:44 +0300, Νίκος Αλεξόπουλος wrote: > Is there something i can try to isolate the problem and make it work? Of course there is. That is part of the job of the developer: hard work trying dozens, maybe hundreds of different things until you isolate the problem. There are no shortcuts, no magic button you can push to immediately identify the source of the problem. If you are not willing to spend hours, maybe days or weeks, working on this problem, then you should hire a programmer who is, and stop fooling yourself that you are a professional developer. An amateur who programs for fun can just give up when a problem becomes too difficult and isn't fun any more. A professional has to keep going. Start by identifying which browsers this occurs on. You should test using at least Firefox, Internet Explorer, Safari, Chrome and Opera, for as many different versions as you can find. You should also test with less common browsers such as Konqueror, Epiphany, lynx, links and others. See if there is a pattern in which ones behave as you expect and which ones don't. You should also test with and without cookies enabled, ad-blockers, and similar. Maybe you can replicate the problem if (say) the user accepts the first cookie, then rejects it when they click Back. If this only occurs with a single version of a single browser with cookies enabled and no ad blocker, you should report it as a bug to the browser developers. Make sure you give them enough detail to replicate the problem. If it's an old version, they'll probably say Won't Fix, and you'll just have to accept that your cookie handling code won't work for some percentage of visitors. Have you checked that the server is setting the cookie values you expect? Have you checked the value of the cookie in the browser? If you don't know how to do these things, this site will teach you everything you need: https://duckduckgo.com/ Follow the links until you reach enlightenment. There are *thousands* of pages on debugging programming problems. If you find it is broken with *all* of the above browsers, then you should suspect a bug in your Python code. In that case, since other people have failed to reproduce the reported problem, you are obviously doing something different than what you are telling us you are doing. Only in this case should you come back here to ask for help with your Python code. Before you do, read this, and follow the instructions: http://www.sscce.org/ If you are not willing to do these things, then stop pretending to be a professional developer, and admit that you are only programming for fun. There is no shame in this -- not everyone is cut out to be a professional programmer, just as not everybody makes a good doctor or taxi driver or carpenter. > By whole counters project is based on cookie handling now.... If you cannot solve the cookie problem, maybe you should reconsider the decision to rely on cookies. -- Steven
[toc] | [prev] | [next] | [standalone]
| From | Νίκος Αλεξόπουλος <nikos.gr33k@gmail.com> |
|---|---|
| Date | 2013-10-09 11:24 +0300 |
| Message-ID | <l333s0$dbc$2@dont-email.me> |
| In reply to | #56458 |
Στις 9/10/2013 4:33 πμ, ο/η Steven D'Aprano έγραψε:
> On Wed, 09 Oct 2013 01:52:44 +0300, Νίκος Αλεξόπουλος wrote:
>
>> Is there something i can try to isolate the problem and make it work?
>
> Of course there is. That is part of the job of the developer: hard work
> trying dozens, maybe hundreds of different things until you isolate the
> problem. There are no shortcuts, no magic button you can push to
> immediately identify the source of the problem.
>
> If you are not willing to spend hours, maybe days or weeks, working on
> this problem, then you should hire a programmer who is, and stop fooling
> yourself that you are a professional developer. An amateur who programs
> for fun can just give up when a problem becomes too difficult and isn't
> fun any more. A professional has to keep going.
>
> Start by identifying which browsers this occurs on. You should test using
> at least Firefox, Internet Explorer, Safari, Chrome and Opera, for as
> many different versions as you can find. You should also test with less
> common browsers such as Konqueror, Epiphany, lynx, links and others. See
> if there is a pattern in which ones behave as you expect and which ones
> don't.
>
> You should also test with and without cookies enabled, ad-blockers, and
> similar. Maybe you can replicate the problem if (say) the user accepts
> the first cookie, then rejects it when they click Back.
>
> If this only occurs with a single version of a single browser with
> cookies enabled and no ad blocker, you should report it as a bug to the
> browser developers. Make sure you give them enough detail to replicate
> the problem. If it's an old version, they'll probably say Won't Fix, and
> you'll just have to accept that your cookie handling code won't work for
> some percentage of visitors.
>
> Have you checked that the server is setting the cookie values you expect?
> Have you checked the value of the cookie in the browser? If you don't
> know how to do these things, this site will teach you everything you need:
>
> https://duckduckgo.com/
>
> Follow the links until you reach enlightenment. There are *thousands* of
> pages on debugging programming problems.
>
> If you find it is broken with *all* of the above browsers, then you
> should suspect a bug in your Python code. In that case, since other
> people have failed to reproduce the reported problem, you are obviously
> doing something different than what you are telling us you are doing.
> Only in this case should you come back here to ask for help with your
> Python code. Before you do, read this, and follow the instructions:
>
> http://www.sscce.org/
>
> If you are not willing to do these things, then stop pretending to be a
> professional developer, and admit that you are only programming for fun.
> There is no shame in this -- not everyone is cut out to be a professional
> programmer, just as not everybody makes a good doctor or taxi driver or
> carpenter.
>
>
>> By whole counters project is based on cookie handling now....
>
> If you cannot solve the cookie problem, maybe you should reconsider the
> decision to rely on cookies.
>
>
>
I managed t overcome it like this:
cur.execute('''UPDATE visitors SET cookieID = %s, host = %s, city = %s,
useros = %s, browser = %s, ref = %s, hits = hits + 1, lastvisit = %s
WHERE counterID = %s and host = %s''',
(cookieID, host, city, useros, browser, ref, lastvisit, cID, host) )
if not cur.rowcount:
# if first time visitor on this page, create new record, if visitor
exists then update record
cur.execute('''INSERT INTO visitors (counterID, cookieID, host, city,
useros, browser, ref, lastvisit) VALUES (%s, %s, %s, %s, %s, %s, %s, %s)
ON DUPLICATE KEY UPDATE host = %s, city = %s, useros = %s, browser = %s,
ref = %s, hits = hits + 1, lastvisit = %s''',
(cID, cookieID, host, city, useros, browser, ref, lastvisit, host, city,
useros, browser, ref, lastvisit) )
But thats a not clear way to handle the cookie because i involve host to
help me identify its recorde since when my website hit comes from areferrer.
i also tried adding the domain when i set the cookie but this didnt
helped me at all:
# initialize cookie and retrieve cookie from clients browser
cookie = cookies.SimpleCookie( os.environ['HTTP_COOKIE'] )
if cookie.get('ID') is not None:
cookieID = cookie['ID'].value
else:
cookieID = random.randrange(0, 9999)
cookie['ID'] = cookieID
cookie['ID']['domain'] = ".superhost.gr"
cookie['ID']['path'] = '/'
cookie["ID"]["expires"] = 60*60*24*365 # this cookie will expire in a year
i read some links from duckduckgo but that didnt help me solve this.
Please someone esle try to reproduce the problem by just using cgi and
not mod_wsgi.
ps. Really why duckduckgo and not google.com ?
[toc] | [prev] | [next] | [standalone]
| From | Mark Lawrence <breamoreboy@yahoo.co.uk> |
|---|---|
| Date | 2013-10-09 09:44 +0100 |
| Message-ID | <mailman.891.1381308272.18130.python-list@python.org> |
| In reply to | #56479 |
On 09/10/2013 09:24, Νίκος Αλεξόπουλος wrote: You have been told repeatedly that your questions have nothing to do with Python, e.g. Ben Finney just over an hour ago "None of this has to do with Python. Please do not ask this Python doscussion forum to educate you on how HTTP operates." Please be courteous enough to take your questions to an appropriate forum. -- Roses are red, Violets are blue, Most poems rhyme, But this one doesn't. Mark Lawrence
[toc] | [prev] | [next] | [standalone]
| From | Denis McMahon <denismfmcmahon@gmail.com> |
|---|---|
| Date | 2013-10-09 14:45 +0000 |
| Message-ID | <l33q6d$341$2@dont-email.me> |
| In reply to | #56479 |
On Wed, 09 Oct 2013 11:24:35 +0300, Νίκος Αλεξόπουλος wrote: > Please someone esle try to reproduce the problem by just using cgi and > not mod_wsgi. I have no intention of reconfiguring my web server just to prove that your code isn't working. We already know that your code isn't working. -- Denis McMahon, denismfmcmahon@gmail.com
[toc] | [prev] | [next] | [standalone]
| From | Piet van Oostrum <piet@vanoostrum.org> |
|---|---|
| Date | 2013-10-09 14:36 -0400 |
| Message-ID | <m2eh7uxpdj.fsf@cochabamba.vanoostrum.org> |
| In reply to | #56479 |
Νίκος Αλεξόπουλος <nikos.gr33k@gmail.com> writes:
>
> # initialize cookie and retrieve cookie from clients browser
> cookie = cookies.SimpleCookie( os.environ['HTTP_COOKIE'] )
>
> if cookie.get('ID') is not None:
> cookieID = cookie['ID'].value
> else:
> cookieID = random.randrange(0, 9999)
> cookie['ID'] = cookieID
> cookie['ID']['domain'] = ".superhost.gr"
> cookie['ID']['path'] = '/'
> cookie["ID"]["expires"] = 60*60*24*365 # this cookie will expire in a year
>
As Ian already has told you (but apparently you didn't pay attention to), your expires is wrong. So if your cookies disappear you should get this right first.
from datetime import datetime, timedelta
expiretime = datetime.utcnow() + timedelta(days=365)
cookie["ID"]["expires"] = expiretime.strftime("%a, %d %b %Y %H:%M:%S GMT")
--
Piet van Oostrum <piet@vanoostrum.org>
WWW: http://pietvanoostrum.com/
PGP key: [8DAE142BE17999C4]
[toc] | [prev] | [next] | [standalone]
| From | Νίκος Αλεξόπουλος <nikos.gr33k@gmail.com> |
|---|---|
| Date | 2013-10-10 00:29 +0300 |
| Message-ID | <l34hrv$t0e$1@dont-email.me> |
| In reply to | #56510 |
Στις 9/10/2013 9:36 μμ, ο/η Piet van Oostrum έγραψε:
> Νίκος Αλεξόπουλος <nikos.gr33k@gmail.com> writes:
>
>>
>> # initialize cookie and retrieve cookie from clients browser
>> cookie = cookies.SimpleCookie( os.environ['HTTP_COOKIE'] )
>>
>> if cookie.get('ID') is not None:
>> cookieID = cookie['ID'].value
>> else:
>> cookieID = random.randrange(0, 9999)
>> cookie['ID'] = cookieID
>> cookie['ID']['domain'] = ".superhost.gr"
>> cookie['ID']['path'] = '/'
>> cookie["ID"]["expires"] = 60*60*24*365 # this cookie will expire in a year
>>
> As Ian already has told you (but apparently you didn't pay attention to), your expires is wrong. So if your cookies disappear you should get this right first.
>
> from datetime import datetime, timedelta
> expiretime = datetime.utcnow() + timedelta(days=365)
>
> cookie["ID"]["expires"] = expiretime.strftime("%a, %d %b %Y %H:%M:%S GMT")
>
Expire is not the issue here, as i have it is working with no problem.
when i print the cookie expiration time is calculated properly.
Something else is going worng.
[toc] | [prev] | [next] | [standalone]
| From | Joel Goldstick <joel.goldstick@gmail.com> |
|---|---|
| Date | 2013-10-09 18:03 -0400 |
| Message-ID | <mailman.909.1381356657.18130.python-list@python.org> |
| In reply to | #56516 |
> > Expire is not the issue here, as i have it is working with no problem. > when i print the cookie expiration time is calculated properly. > Something else is going worng. > Indeed! > -- > https://mail.python.org/mailman/listinfo/python-list -- Joel Goldstick http://joelgoldstick.com
[toc] | [prev] | [next] | [standalone]
Page 1 of 3 [1] 2 3 Next page →
Back to top | Article view | comp.lang.python
csiph-web