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


Groups > comp.lang.python > #56479

Re: Cookie gets changed when hit comes from a referrer

From Νίκος Αλεξόπουλος <nikos.gr33k@gmail.com>
Newsgroups comp.lang.python
Subject Re: Cookie gets changed when hit comes from a referrer
Date 2013-10-09 11:24 +0300
Organization A noiseless patient Spider
Message-ID <l333s0$dbc$2@dont-email.me> (permalink)
References (1 earlier) <l319sl$cl6$3@dont-email.me> <l31aek$dd5$1@dont-email.me> <l31mf8$cl6$4@dont-email.me> <l322bq$1ll$1@dont-email.me> <5254b264$0$29984$c3e8da3$5496439d@news.astraweb.com>

Show all headers | View raw


Στις 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 ?

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


Thread

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

csiph-web