Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Cookie gets changed when hit comes from a referrer

92 views
Skip to first unread message

Νίκος Αλεξόπουλος

unread,
Oct 8, 2013, 6:04:34 AM10/8/13
to
# 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?

Ian Kelly

unread,
Oct 8, 2013, 7:08:06 AM10/8/13
to Python
On Tue, Oct 8, 2013 at 4:04 AM, Νίκος Αλεξόπουλος <nikos...@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.

Νίκος Αλεξόπουλος

unread,
Oct 8, 2013, 10:18:12 AM10/8/13
to
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>

Νίκος Αλεξόπουλος

unread,
Oct 8, 2013, 10:36:50 AM10/8/13
to
Στις 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?

Denis McMahon

unread,
Oct 8, 2013, 11:55:01 AM10/8/13
to
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, denismf...@gmail.com

Νίκος Αλεξόπουλος

unread,
Oct 8, 2013, 12:04:37 PM10/8/13
to
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?

Νίκος Αλεξόπουλος

unread,
Oct 8, 2013, 1:30:48 PM10/8/13
to
Is there any better way to identif a previous visitor? i tried cookies
which failed for me for the reason i opened this thread and host like
follows:

# try to locate the visitor
cur.execute('''SELECT * FROM visitors WHERE counterID = %s and host =
%s''', (cID, host) )
data = cur.fetchone()

if not data:
# if first time visitor on this page, create new record
cur.execute('''INSERT INTO visitors (counterID, host, city, useros,
browser, ref, lastvisit) VALUES (%s, %s, %s, %s, %s, %s, %s)''',
(cID, host, city, useros, browser, ref, lastvisit) )
else:
# since visitor exists just update his record
cur.execute('''UPDATE visitors SET city = %s, useros = %s, browser =
%s, ref = %s, hits = hits + 1, lastvisit = %s''', (city, useros,
browser, ref, lastvisit) )
=======

Please tell me if you can think fo something else.

Joel Goldstick

unread,
Oct 8, 2013, 1:47:14 PM10/8/13
to Νίκος Αλεξόπουλος, pytho...@python.org
Yes! there is a very simple and comprehensive way to learn about your
visitors. Use Google Analytics. Its free, you only need a google
account to open an analytics account. They give you a small bit of
javascript that you copy and past to your pages. If you are using a
template to create your pages, this is easy, since you just add google
code to the template.
>
> --
> https://mail.python.org/mailman/listinfo/python-list



--
Joel Goldstick
http://joelgoldstick.com

Joel Goldstick

unread,
Oct 8, 2013, 1:10:52 PM10/8/13
to Νίκος Αλεξόπουλος, pytho...@python.org
On Tue, Oct 8, 2013 at 12:04 PM, Νίκος Αλεξόπουλος
<nikos...@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!

Denis McMahon

unread,
Oct 8, 2013, 3:29:44 PM10/8/13
to
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, denismf...@gmail.com

Νίκος Αλεξόπουλος

unread,
Oct 8, 2013, 6:52:44 PM10/8/13
to
Is there something i can try to isolate the problem and make it work?
By whole counters project is based on cookie handling now....

Ned Batchelder

unread,
Oct 8, 2013, 7:57:33 PM10/8/13
to Νίκος Αλεξόπουλος, pytho...@python.org
Nikos, as a few people have mentioned already, this is no longer a
Python question. You need to find other avenues of support.

--Ned.

Steven D'Aprano

unread,
Oct 8, 2013, 9:24:10 PM10/8/13
to
On Tue, 08 Oct 2013 13:47:14 -0400, Joel Goldstick wrote:

> Yes! there is a very simple and comprehensive way to learn about your
> visitors. Use Google Analytics. Its free, you only need a google
> account to open an analytics account.

http://images.wikia.com/darkheresy/images/0/0c/Its_a_trap.jpg

There is a very simple and comprehensive way for Google to learn about
your visitors: Google Analytics.



--
Steven

Steven D'Aprano

unread,
Oct 8, 2013, 9:33:25 PM10/8/13
to
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

Ian Kelly

unread,
Oct 9, 2013, 12:53:53 AM10/9/13
to Python
On Tue, Oct 8, 2013 at 8:18 AM, Νίκος Αλεξόπουλος <nikos...@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.

Νίκος Αλεξόπουλος

unread,
Oct 9, 2013, 2:47:29 AM10/9/13
to
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?

Mark Lawrence

unread,
Oct 9, 2013, 3:00:16 AM10/9/13
to pytho...@python.org
On 08/10/2013 23:52, Νίκος Αλεξόπουλος wrote:

>
> Is there something i can try to isolate the problem and make it work?
>

As you are the problem why not try solitary confinement? :)

--
Roses are red,
Violets are blue,
Most poems rhyme,
But this one doesn't.

Mark Lawrence

Ben Finney

unread,
Oct 9, 2013, 3:12:21 AM10/9/13
to pytho...@python.org
Νίκος Αλεξόπουλος <nikos...@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

Νίκος Αλεξόπουλος

unread,
Oct 9, 2013, 4:24:35 AM10/9/13
to
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 ?

Mark Lawrence

unread,
Oct 9, 2013, 4:44:15 AM10/9/13
to pytho...@python.org
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.

Denis McMahon

unread,
Oct 9, 2013, 10:43:03 AM10/9/13
to
On Wed, 09 Oct 2013 01:52:44 +0300, Νίκος Αλεξόπουλος wrote:

See those last two paragraphs there that you quoted. You should have read
them.

--
Denis McMahon, denismf...@gmail.com

Denis McMahon

unread,
Oct 9, 2013, 10:45:33 AM10/9/13
to
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, denismf...@gmail.com

Νίκος Αλεξόπουλος

unread,
Oct 9, 2013, 11:00:28 AM10/9/13
to
ok so then tell me where i should ask this.

Joel Goldstick

unread,
Oct 9, 2013, 11:20:07 AM10/9/13
to Νίκος Αλεξόπουλος, pytho...@python.org
I already told you where to learn about cookies. Try that first.
People will be nicer to your questions if you show you are willing to
come prepared. As to where to ask -- perhaps there is an http mailing
list. Your code can't work if you don't know how cookies work.

Mark Lawrence

unread,
Oct 9, 2013, 11:39:34 AM10/9/13
to pytho...@python.org
On 09/10/2013 16:00, Νίκος Αλεξόπουλος wrote:

> ok so then tell me where i should ask this.
>

Google, bing, duckduckgo, ask, yahoo ...

Denis McMahon

unread,
Oct 9, 2013, 2:06:05 PM10/9/13
to
In those two paragraphs I have told you what you need to do to isolate
where your problem is occurring. If you don't know how to do that, then I
commend to you the wealth of information that may be discovered using
search engines. However, as we keep telling you, this group is not the
right place to ask questions such as:

a) How do I see what's in my web browser's cookie jar?
b) How do I make my web server log the cookies it sends and receives?

For (a) you want information about your browser, not about python.
For (b) you want information about your web server, not about python.

Find the relevant forums and ask in them.

--
Denis McMahon, denismf...@gmail.com

Denis McMahon

unread,
Oct 9, 2013, 2:06:36 PM10/9/13
to
In those two paragraphs I have told you what you need to do to isolate
where your problem is occurring. If you don't know how to do that, then I
commend to you the wealth of information that may be discovered using
search engines. However, as we keep telling you, this group is not the
right place to ask questions such as:

a) How do I see what's in my web browser's cookie jar?
b) How do I make my web server log the cookies it sends and receives?

For (a) you want information about your browser, not about python.
For (b) you want information about your web server, not about python.

Find the relevant forums and ask in them.

--
Denis McMahon, denismf...@gmail.com

Mark Lawrence

unread,
Oct 9, 2013, 2:28:06 PM10/9/13
to pytho...@python.org
On 09/10/2013 19:06, Denis McMahon wrote:
>
> Find the relevant forums and ask in them.
>

Why am I thinking of this
http://en.wikipedia.org/wiki/There%27s_a_Hole_in_My_Bucket ?

Piet van Oostrum

unread,
Oct 9, 2013, 2:36:56 PM10/9/13
to
Νίκος Αλεξόπουλος <nikos...@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 <pi...@vanoostrum.org>
WWW: http://pietvanoostrum.com/
PGP key: [8DAE142BE17999C4]

Tim Chase

unread,
Oct 9, 2013, 3:26:12 PM10/9/13
to Mark Lawrence, pytho...@python.org
On 2013-10-09 19:28, Mark Lawrence wrote:
> On 09/10/2013 19:06, Denis McMahon wrote:
>> Find the relevant forums and ask in them.
>
There's a bug in my program, dear newsgroup, dear newsgroup,
There's a bug in my program, dear newsgroup a bug.

Then fix it, dear Nikos, dear Nikos, dear Nikos,
Then fix it, dear Nikos, dear Nikos, fix it.

With what shall I fix it, dear newsgroup, dear newsgroup,
With what shall I fix it, dear newsgroup, with what?

The traceback, dear Nikos, dear Nikos, dear Nikos,
The traceback, dear Nikos, dear Nikos, traceback.

The problem's not Python, dear newsgroup, dear newsgroup,
The problem's not Python, dear newsgroup, what now?

Try Google, dear Nikos, dear Nikos, dear Nikos,
Try Google, dear Nikos, dear Nikos, Google.

But what shall I query, dear newsgroup, dear newsgroup,
But what shall I query, dear newsgroup, but what?

Some keywords, dear Nikos, dear Nikos, dear Nikos,
Some keywords, dear Nikos, dear Nikos, keywords.

I know it's off-topic, dear newsgroup, dear newsgroup,
I know it's off-topic, dear newsgroup, but help...


I can see the similarity ;-)

-tkc






Mark Lawrence

unread,
Oct 9, 2013, 3:40:21 PM10/9/13
to pytho...@python.org
On 09/10/2013 20:26, Tim Chase wrote:
> On 2013-10-09 19:28, Mark Lawrence wrote:
>> On 09/10/2013 19:06, Denis McMahon wrote:
>>> Find the relevant forums and ask in them.
>>
>> Why am I thinking of this
>> http://en.wikipedia.org/wiki/There%27s_a_Hole_in_My_Bucket ?
>
> There's a bug in my program, dear newsgroup, dear newsgroup,
> There's a bug in my program, dear newsgroup a bug.
>
> Then fix it, dear Nikos, dear Nikos, dear Nikos,
> Then fix it, dear Nikos, dear Nikos, fix it.
>
> With what shall I fix it, dear newsgroup, dear newsgroup,
> With what shall I fix it, dear newsgroup, with what?
>
> The traceback, dear Nikos, dear Nikos, dear Nikos,
> The traceback, dear Nikos, dear Nikos, traceback.
>
> The problem's not Python, dear newsgroup, dear newsgroup,
> The problem's not Python, dear newsgroup, what now?
>
> Try Google, dear Nikos, dear Nikos, dear Nikos,
> Try Google, dear Nikos, dear Nikos, Google.
>
> But what shall I query, dear newsgroup, dear newsgroup,
> But what shall I query, dear newsgroup, but what?
>
> Some keywords, dear Nikos, dear Nikos, dear Nikos,
> Some keywords, dear Nikos, dear Nikos, keywords.
>
> I know it's off-topic, dear newsgroup, dear newsgroup,
> I know it's off-topic, dear newsgroup, but help...
>
>
> I can see the similarity ;-)
>
> -tkc
>

Great minds think alike? :)

Νίκος Αλεξόπουλος

unread,
Oct 9, 2013, 5:29:38 PM10/9/13
to
Στις 9/10/2013 9:36 μμ, ο/η Piet van Oostrum έγραψε:
> Νίκος Αλεξόπουλος <nikos...@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.

Joel Goldstick

unread,
Oct 9, 2013, 6:03:09 PM10/9/13
to Νίκος Αλεξόπουλος, pytho...@python.org
>
> 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

Mark Lawrence

unread,
Oct 9, 2013, 6:26:25 PM10/9/13
to pytho...@python.org
On 09/10/2013 23:03, Joel Goldstick wrote:
>>
>> 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!
>

Well explained here http://en.wikipedia.org/wiki/User_error

Steven D'Aprano

unread,
Oct 9, 2013, 7:48:12 PM10/9/13
to
On Wed, 09 Oct 2013 18:06:05 +0000, Denis McMahon wrote:

> Find the relevant forums and ask in them.

In fairness to Nikos, that may not be an easy thing to do. I for one have
*no idea* where to find an appropriate forum to learn about these sorts
of web basics. comp.protocol.http doesn't exist :-)

I'm pretty sure that everyone here has been in this situation. We've
pretty much all asked for recommendations "where is a good place to learn
about X?", for some definition of X. That is a reasonable question, and
"just google it" is *not* a reasonable answer, because search engines are
not good at that sort of value judgement. Human beings are. And even the
best of us have had days were we simply cannot come up with good search
terms that find us what we need.

So, for the benefit of anyone, not just Nikos, who wants to learn about
how browsers connect to web sites and how to run a web server, does
anyone have any recommendation for tutorials, mailing lists, web forums
or books which are suitable? Preferably things you have used yourself,
and can personally vouch for being useful.

I'm pretty sure that *somebody* here has been in the position of needing
to learn about running a website, and can point Nikos in the right
direction (away from here). How did you learn?

And if nobody is able, or willing, to answer? I've been in that position
too, asking for help that nobody was able to give. It sucks, and you move
on and do your best.


--
Steven

Chris Angelico

unread,
Oct 9, 2013, 8:18:55 PM10/9/13
to pytho...@python.org
On Thu, Oct 10, 2013 at 10:48 AM, Steven D'Aprano
<steve+comp....@pearwood.info> wrote:
> So, for the benefit of anyone, not just Nikos, who wants to learn about
> how browsers connect to web sites and how to run a web server, does
> anyone have any recommendation for tutorials, mailing lists, web forums
> or books which are suitable? Preferably things you have used yourself,
> and can personally vouch for being useful.

Personally, what I find most useful is network-level tracing - if I
want to know what my web server's doing, I'll telnet to it (or, more
likely, use my MUD client) and look at exactly what it's sending; and
if I want to know what a browser's doing, I'll do the same (since my
MUD clients allow me to run them "backwards", listening rather than
connecting).

But that isn't for everyone, I'm aware of that.

ChrisA

Denis McMahon

unread,
Oct 9, 2013, 8:31:06 PM10/9/13
to
On Wed, 09 Oct 2013 23:48:12 +0000, Steven D'Aprano wrote:

> On Wed, 09 Oct 2013 18:06:05 +0000, Denis McMahon wrote:
>
>> Find the relevant forums and ask in them.
>
> In fairness to Nikos, that may not be an easy thing to do. I for one
> have *no idea* where to find an appropriate forum to learn about these
> sorts of web basics. comp.protocol.http doesn't exist :-)

If Nikos wants to write programs that communicate using internet
protocols, Nikos really needs to learn where internet protocols are
defined, how to read and interpret those protocol definitions, and how to
check that the data he's sending or receiving is the data that he thinks
he's sending or receiving.

Just as, if Nikos wants to generate web pages using HTML markup, Nikos
needs to learn where HTML markup is defined.

There's no easy path to this knowledge. For some of us, it's been a 30 or
more year journey so far and we're still learning (I'm into year 36,
having started at the age of 14 and turning 51 in seven weeks).

If Nikos can't even figure out the right queries to feed into a search
engine to get started on such matters as looking at the cookie jar in a
browser or enabling cookie logging on a server, then he probably
shouldn't be trying to code at this level.

--
Denis McMahon, denismf...@gmail.com

Ben Finney

unread,
Oct 9, 2013, 8:43:50 PM10/9/13
to pytho...@python.org
Steven D'Aprano <steve+comp....@pearwood.info> writes:

> So, for the benefit of anyone, not just Nikos, who wants to learn
> about how browsers connect to web sites and how to run a web server,
> does anyone have any recommendation for tutorials, mailing lists, web
> forums or books which are suitable? Preferably things you have used
> yourself, and can personally vouch for being useful.

I learned a lot from reading the documents at the W3C, since they
defined the standards we all use <URL:http://www.w3.org/standards/>.
They are very well written and explain a lot about the architecture of
the Web.

> I'm pretty sure that *somebody* here has been in the position of
> needing to learn about running a website, and can point Nikos in the
> right direction (away from here). How did you learn?

Experiment, observation, and reference to standards.

> And if nobody is able, or willing, to answer? I've been in that
> position too, asking for help that nobody was able to give. It sucks,
> and you move on and do your best.

Right. What you don't do is disrupt a discussion forum by bombarding it
with off-topic requests; that's a quick way to get a community turn
against you.

--
\ “I have yet to see any problem, however complicated, which, |
`\ when you looked at it in the right way, did not become still |
_o__) more complicated.” —Paul Anderson |
Ben Finney

Roy Smith

unread,
Oct 9, 2013, 8:58:54 PM10/9/13
to
In article <5255eb3c$0$29984$c3e8da3$5496...@news.astraweb.com>,
Steven D'Aprano <steve+comp....@pearwood.info> wrote:

> So, for the benefit of anyone, not just Nikos, who wants to learn about
> how browsers connect to web sites and how to run a web server, does
> anyone have any recommendation for tutorials, mailing lists, web forums
> or books which are suitable? Preferably things you have used yourself,
> and can personally vouch for being useful.

In the way of tools, tcpdump (or wireshark, or whatever packet sniffer
you have handy) is invaluable for seeing what's really going on. Also,
curl is an amazing tool for sending arbitrary requests to a HTTP server.
It's got a zillion options. You'll want to learn what most of them do.
The combination of curl and tcpdump is a pretty potent weapon for poking
at servers.

An interesting alternative to tcpdump/curl is Google Chrome. Open up
the developer tools (Command-Option-I on the Mac), click the network
tab, and type a request into the address bar. It will capture the
outgoing request and the response you get back, and let you dig into
them in as much detail as you want. Very handy, at least for GET
requests. I imagine any decent browser has similar functionality.


For general background, I would start with
https://en.wikipedia.org/wiki/Http and keep following links from there
until you have read the whole wiki or gotten tired, whichever comes
first.

stackoverflow has become a really good forum for asking all sorts of
programming-related questions (although, its sister site, serverfault,
is more appropriate for networking questions). I find the U/I
confusing, and often find the rules (i.e. what's allowed and what's not)
kind of silly, but a lot of really smart people hang out there. If you
want a question answered, go where the smart people are.

> I'm pretty sure that *somebody* here has been in the position of needing
> to learn about running a website, and can point Nikos in the right
> direction (away from here).

I guarantee the folks on either stackoverflow or serverfault won't put
up with the kind of bullcrap that has been pervading this group as of
late.

If I was using a program, foo, and had a problem, the first thing I
would do is google for "foo mailing list" and see if I can find one.
You don't always find one, and sometimes the list is dead, but it's a
good place to start.

> How did you learn?

Run. Fall down. Get up. Start running again. Repeat as needed.

Steven D'Aprano

unread,
Oct 9, 2013, 9:10:19 PM10/9/13
to
On Thu, 10 Oct 2013 00:31:06 +0000, Denis McMahon wrote:

> On Wed, 09 Oct 2013 23:48:12 +0000, Steven D'Aprano wrote:
>
>> On Wed, 09 Oct 2013 18:06:05 +0000, Denis McMahon wrote:
>>
>>> Find the relevant forums and ask in them.
>>
>> In fairness to Nikos, that may not be an easy thing to do. I for one
>> have *no idea* where to find an appropriate forum to learn about these
>> sorts of web basics. comp.protocol.http doesn't exist :-)
>
> If Nikos wants to write programs that communicate using internet
> protocols, Nikos really needs to learn where internet protocols are
> defined, how to read and interpret those protocol definitions, and how
> to check that the data he's sending or receiving is the data that he
> thinks he's sending or receiving.

You can't seriously mean that everyone who runs a website has to become
skilled at reading and interpreting the RFCs for "internet protocols".
Which protocols? All the way down to TCP/IP?


> Just as, if Nikos wants to generate web pages using HTML markup, Nikos
> needs to learn where HTML markup is defined.
>
> There's no easy path to this knowledge. For some of us, it's been a 30
> or more year journey so far and we're still learning (I'm into year 36,
> having started at the age of 14 and turning 51 in seven weeks).
>
> If Nikos can't even figure out the right queries to feed into a search
> engine to get started on such matters as looking at the cookie jar in a
> browser or enabling cookie logging on a server, then he probably
> shouldn't be trying to code at this level.

Nikos Nikos Nikos... and what about me? If I asked you for a few pointers
about a good place to learn about running a web site, would you tell me
to fuck off too? I wonder what you are doing here, if you are so
unwilling to share your hard-earned knowledge with others as you seem in
this post. This attitude is not the Denis McMahon I'm used to.

Honestly, your response seems to me to be just a more verbose way of
saying "RTFM n00b", and about as helpful. Speaking for myself, I don't
want this forum to be the sort of place where that is considered an
appropriate response, no matter how politely the dismissal is dressed up.

I'm here to help people, and yes, that even means Nikos. To give back to
the community that helped me (and continues to help me). In my opinion,
if we're going to tell people to RTFM the least we can do is point them
at the right manual, and not just dismiss them by telling them to google
it. I don't think that's too much to ask.

(On the other hand, it's okay to say "I don't know of any good forums for
learning this stuff. Sorry mate, I can't help.")

I have no objection to encouraging people to read the fine manual, and I
don't intend to be Nikos' (or anyone else's) unpaid full-time help desk
and troubleshooter. But I do think it is simply unfair to treat him more
harshly than we would others in the same position. If *anyone else* asked
for help on these sorts of network and browser questions, we'd give them
more constructive pointers than just "google it".

Nikos, are you reading this? This is what happens when you behave like a
royal pain in the arse and annoy people. They stop wanting to help you.
Be told. Learn from this. Don't repeat this mistake in the next forum. If
you learn nothing else, learn that lesson.


--
Steven

Chris Angelico

unread,
Oct 9, 2013, 9:28:31 PM10/9/13
to pytho...@python.org
On Thu, Oct 10, 2013 at 12:10 PM, Steven D'Aprano
<steve+comp....@pearwood.info> wrote:
> On Thu, 10 Oct 2013 00:31:06 +0000, Denis McMahon wrote:
>
>> On Wed, 09 Oct 2013 23:48:12 +0000, Steven D'Aprano wrote:
>>
>>> On Wed, 09 Oct 2013 18:06:05 +0000, Denis McMahon wrote:
>>>
>>>> Find the relevant forums and ask in them.
>>>
>>> In fairness to Nikos, that may not be an easy thing to do. I for one
>>> have *no idea* where to find an appropriate forum to learn about these
>>> sorts of web basics. comp.protocol.http doesn't exist :-)
>>
>> If Nikos wants to write programs that communicate using internet
>> protocols, Nikos really needs to learn where internet protocols are
>> defined, how to read and interpret those protocol definitions, and how
>> to check that the data he's sending or receiving is the data that he
>> thinks he's sending or receiving.
>
> You can't seriously mean that everyone who runs a website has to become
> skilled at reading and interpreting the RFCs for "internet protocols".
> Which protocols? All the way down to TCP/IP?

Certainly not; but if he's run into trouble with cookies, I think it's
not too much to ask him to read:
http://en.wikipedia.org/wiki/HTTP_cookie
It has a lot of text, but quite a bit of it is likely to be of use.
Then there's links down the bottom to an RFC, to Mozilla, and so on,
which could also be of use. Half an hour spent reading there will pay
good dividends.

> ... I do think it is simply unfair to treat him more
> harshly than we would others in the same position. If *anyone else* asked
> for help on these sorts of network and browser questions, we'd give them
> more constructive pointers than just "google it".
>
> Nikos, are you reading this? This is what happens when you behave like a
> royal pain in the arse and annoy people. They stop wanting to help you.
> Be told. Learn from this. Don't repeat this mistake in the next forum. If
> you learn nothing else, learn that lesson.

Actually no, it's not unfair to treat him more harshly. What's unfair
is that he hasn't been banned, killfiled by everyone, or in some other
way completely cut off from assistance. It's just as unfair as the
mercy God shows to us. We're being extremely unjust in helping him...
he hasn't earned anything, he hasn't merited help, he's not paying us.
It's a gift, it's free service, and it's a privilege. Nikos, rejoice
in the unfair and inconceivably merciful state of this forum, and as
Steven says, learn from it and don't make the same mistake elsewhere.

(I've made that mistake myself, too. I've made myself a stench in the
nostrils of certain communities. It's not something you can't come
back from; it's part of life, part of learning.)

ChrisA

Mark Lawrence

unread,
Oct 10, 2013, 1:21:57 AM10/10/13
to pytho...@python.org
On 10/10/2013 02:28, Chris Angelico wrote:
>
> Half an hour spent reading there will pay
> good dividends.
>

That's been sadly lacking in all of these threads. With responses
coming back faster than a ball on the centre court at Wimbledon, it's
hardly surprising that progress has been conspicious by its absence.

rusi

unread,
Oct 10, 2013, 1:36:54 AM10/10/13
to
On Thursday, October 10, 2013 6:40:19 AM UTC+5:30, Steven D'Aprano wrote:
>
> I have no objection to encouraging people to read the fine manual, and I
> don't intend to be Nikos' (or anyone else's) unpaid full-time help desk
> and troubleshooter. But I do think it is simply unfair to treat him more
> harshly than we would others in the same position. If *anyone else* asked
> for help on these sorts of network and browser questions, we'd give them
> more constructive pointers than just "google it".

https://mail.python.org/pipermail/python-list/2013-October/657221.html

https://mail.python.org/pipermail/python-list/2013-October/657034.html

Mark Lawrence

unread,
Oct 10, 2013, 1:56:17 AM10/10/13
to pytho...@python.org
I don't understand you point, please explain.

Ben Finney

unread,
Oct 10, 2013, 2:01:25 AM10/10/13
to pytho...@python.org
rusi <rusto...@gmail.com> writes:

> On Thursday, October 10, 2013 6:40:19 AM UTC+5:30, Steven D'Aprano wrote:
> > If *anyone else* asked for help on these sorts of network and
> > browser questions, we'd give them more constructive pointers than
> > just "google it".

Someone who has so consistently demonstrated their unwillingness to
learn, and their persistent arrogance in flooding this forum with
demands for assistance, is quite deserving of curt “go and find out for
yourself, leave this forum alone” responses.

We are a, and should remain, an open and tolerant community. But the
persistently disrespectful actions of Nikos threaten the forum's value
and usefulness for everyone else. There are limits to how much
disruption and obstinacy this community should tolerate from a given
individual.

> https://mail.python.org/pipermail/python-list/2013-October/657221.html
> https://mail.python.org/pipermail/python-list/2013-October/657034.html

Both of which got quite helpful responses: a brief, polite referral to
seek a specific discussion forum where their requests would be on topic.

--
\ “If nature has made any one thing less susceptible than all |
`\ others of exclusive property, it is the action of the thinking |
_o__) power called an idea” —Thomas Jefferson |
Ben Finney

Steven D'Aprano

unread,
Oct 10, 2013, 3:18:10 AM10/10/13
to
On Wed, 09 Oct 2013 22:36:54 -0700, rusi wrote:

> On Thursday, October 10, 2013 6:40:19 AM UTC+5:30, Steven D'Aprano
> wrote:
>>
>> I have no objection to encouraging people to read the fine manual, and
>> I don't intend to be Nikos' (or anyone else's) unpaid full-time help
>> desk and troubleshooter. But I do think it is simply unfair to treat
>> him more harshly than we would others in the same position. If *anyone
>> else* asked for help on these sorts of network and browser questions,
>> we'd give them more constructive pointers than just "google it".
>
> https://mail.python.org/pipermail/python-list/2013-October/657221.html

That's a good example of exactly the sort of thing I'm talking about.
Joel responded with "have you checked the pysvn mailing list" and gave a
URL to that list. That is a good, helpful response, given that we can't
be expected to know everything about every arbitrary package that might
use Python.


> https://mail.python.org/pipermail/python-list/2013-October/657034.html

And even this got a response suggesting the poster look for an nginx
mailing list, which while less helpful than it could have been, was still
a concrete, helpful response: not "RTFM", or "just google it", but
"that's a problem with nginx, you need an nginx forum, not a Python one".



--
Steven

Steven D'Aprano

unread,
Oct 10, 2013, 3:20:07 AM10/10/13
to
On Thu, 10 Oct 2013 17:01:25 +1100, Ben Finney wrote:

> There are limits to how much disruption and obstinacy this community
> should tolerate from a given individual.

I think we are in violent agreement :-)

It's possible we disagree about where to draw the line, and whether
persistent cluelessness counts as wilful disruption, but otherwise I'm
not disagreeing with you.



--
Steven

Tim Golden

unread,
Oct 10, 2013, 3:44:16 AM10/10/13
to pytho...@python.org
On 10/10/2013 00:48, Steven D'Aprano wrote:
> So, for the benefit of anyone, not just Nikos, who wants to learn about
> how browsers connect to web sites and how to run a web server, does
> anyone have any recommendation for tutorials, mailing lists, web forums
> or books which are suitable? Preferably things you have used yourself,
> and can personally vouch for being useful.

Not that it's a free resource, but I found this O'Reilly pocket guide
useful as a starter. It's not too expensive either.

http://shop.oreilly.com/product/9781565928626.do

I bought it for my Dad who's a retired civil engineer now happily
engaged in setting up small websites for Parish groups and the like.
Exactly the kind of thing where he can experiment with a bit of
wackiness without people minding too much if things go wrong... (And he
does have a test rig at home).

As clearly evidenced by the wide range of reactions one sees in answer
to "What's the best book...?" questions here, different people have
wildly different learning styles. For some, going to the RFCs is
*exactly* what they find interesting & illuminating. For others, a
step-by-step with screenshots is more the thing, etc.

TJG

Antoon Pardon

unread,
Oct 10, 2013, 4:50:25 AM10/10/13
to pytho...@python.org
Op 10-10-13 03:10, Steven D'Aprano schreef:
> On Thu, 10 Oct 2013 00:31:06 +0000, Denis McMahon wrote:
>>
>> If Nikos can't even figure out the right queries to feed into a search
>> engine to get started on such matters as looking at the cookie jar in a
>> browser or enabling cookie logging on a server, then he probably
>> shouldn't be trying to code at this level.
>
> Nikos Nikos Nikos... and what about me? If I asked you for a few pointers
> about a good place to learn about running a web site, would you tell me
> to fuck off too? I wonder what you are doing here, if you are so
> unwilling to share your hard-earned knowledge with others as you seem in
> this post. This attitude is not the Denis McMahon I'm used to.

A year ago no. Now yes! Because you are behaving like an enabler. Nikos
is the prime cause of the disruptions here and you are asking we should
treat him as if he is a well behaving regular that comes with the
occasional off topic question.

You seem unable or unwilling to draw a line in how far we should go in
enduring Nikos's anti-social behaviour. You seem unable to grasp that
how we treat people depends on their behaviour in the past.

> Honestly, your response seems to me to be just a more verbose way of
> saying "RTFM n00b", and about as helpful. Speaking for myself, I don't
> want this forum to be the sort of place where that is considered an
> appropriate response, no matter how politely the dismissal is dressed up.

But you are cooperating very hard in producing just that. By ignoring
the reasons people react harshly to Nikos and pretending such a
reaction is a reflection on how they would treat newbies in general you
are being extremely unfair.

> I'm here to help people, and yes, that even means Nikos. To give back to
> the community that helped me (and continues to help me). In my opinion,
> if we're going to tell people to RTFM the least we can do is point them
> at the right manual, and not just dismiss them by telling them to google
> it. I don't think that's too much to ask.

And how far are you willing to go with this help? Right now you are
helping Nikos in his anti-social behaviour. Is that your idea of giving
back to the community? Annoying a significant part of it in your quest
to help people?

> (On the other hand, it's okay to say "I don't know of any good forums for
> learning this stuff. Sorry mate, I can't help.")
>
> I have no objection to encouraging people to read the fine manual, and I
> don't intend to be Nikos' (or anyone else's) unpaid full-time help desk
> and troubleshooter. But I do think it is simply unfair to treat him more
> harshly than we would others in the same position. If *anyone else* asked
> for help on these sorts of network and browser questions, we'd give them
> more constructive pointers than just "google it".

We don't. The history peope have on this forum is part of the position
they are in. If someone has abused the hospitality of an environment,
then there is nothing wrong if that environment starts reacting hostile.
That is the *situation* Nikos is in now. So stop pretending any regular
asking an occasional off topic question would be the same situation.

--
Antoon Pardon

Denis McMahon

unread,
Oct 10, 2013, 9:42:16 AM10/10/13
to
On Thu, 10 Oct 2013 01:10:19 +0000, Steven D'Aprano wrote:

>> If Nikos wants to write programs that communicate using internet
>> protocols, Nikos really needs to learn where internet protocols are
>> defined, how to read and interpret those protocol definitions, and how
>> to check that the data he's sending or receiving is the data that he
>> thinks he's sending or receiving.
>
> You can't seriously mean that everyone who runs a website has to become
> skilled at reading and interpreting the RFCs for "internet protocols".
> Which protocols? All the way down to TCP/IP?

I'm not talking about running a website, I'm talking about writing code
that uses specific protocols to transfer data. If Nikos is writing code
that uses http, then he needs to understand http.

His previous questions relating to his wish to spoof ip addresses
suggests that in his case, he needs to understand tcp/ip as well.

I'm not suggesting that every web admin needs to know these, but anyone
who is trying to talk at the protocol level needs to understand the
protocol, yes.

> Nikos Nikos Nikos... and what about me? If I asked you for a few
> pointers about a good place to learn about running a web site, would you
> tell me to fuck off too? I wonder what you are doing here, if you are so
> unwilling to share your hard-earned knowledge with others as you seem in
> this post. This attitude is not the Denis McMahon I'm used to.

I'm not unwilling, but this forum is not the place for tcp/ip 101, or
http 101, or smtp 101, or dns 101, or geolocation 101, despite Nkos'
attempts to turn it into one. This forum is a place for python coding.

> Nikos, are you reading this? This is what happens when you behave like a
> royal pain in the arse and annoy people. They stop wanting to help you.
> Be told. Learn from this. Don't repeat this mistake in the next forum.
> If you learn nothing else, learn that lesson.

Yes, this is exactly the issue. I am so pissed off with trying to help
Nikos and being told things like "Your solution is crap because you use
too many lines, even though it works, unlike my [Nikos's] single line
effort which I [Nikos] think looks aesthetically wonderful and which must
therefore be the superior solution even though it doesn't work".

I went so far as to set up mod-wsgi on my server simply to try and
understand his cookie issues - before that I hadn't used python on my
apache server except at the basic cgi level. I managed to get a
functional cookie implementation up and running within a few hours,
primarily by reading the relevant api documentation, and looking up a few
examples on slashdot and similar.

Given that Nikos presents as being a professional coder developing client
facing facing python code for a hosting provider, his inability to do
something similar, indeed his inability to locate relevant sources of
information, is frankly quite astounding, and I am in agreement with the
many others on this forum who regularly and frequently voice the opinion
that Nikos, specifically, has no business coding anything on a web server.

--
Denis McMahon, denismf...@gmail.com
Message has been deleted
Message has been deleted
0 new messages