Cookie gets changed when hit comes from a referrer

  • Thread starter Îίκος Αλεξόπουλος
  • Start date
D

Denis McMahon

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.
 
Î

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

Στις 9/10/2013 5:43 μμ, ο/η Denis McMahon έγÏαψε:
See those last two paragraphs there that you quoted. You should have read
them.
ok so then tell me where i should ask this.
 
J

Joel Goldstick

Στις 9/10/2013 5:43 μμ, ο/η DenisMcMahon έγÏαψε:

ok so then tell me where i should ask this.


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.
 
M

Mark Lawrence

ok so then tell me where i should ask this.

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

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

Mark Lawrence
 
D

Denis McMahon

Στις 9/10/2013 5:43 μμ, ο/η Denis McMahon έγÏαψε:
ok so then tell me where i should ask this.

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.
 
D

Denis McMahon

Στις 9/10/2013 5:43 μμ, ο/η Denis McMahon έγÏαψε:
ok so then tell me where i should ask this.

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.
 
P

Piet van Oostrum

Îίκος Αλεξόπουλος said:
# 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")
 
T

Tim Chase


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
 
M

Mark Lawrence

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? :)

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

Mark Lawrence
 
Î

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

Στις 9/10/2013 9:36 μμ, ο/η Piet van Oostrum έγÏαψε:
Îίκος Αλεξόπουλος said:
# 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.
 
J

Joel Goldstick

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!
 
S

Steven D'Aprano

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.
 
C

Chris Angelico

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
 
D

Denis McMahon

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.
 
R

Roy Smith

Steven D'Aprano said:
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.
 
S

Steven D'Aprano

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 **** 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.
 
C

Chris Angelico

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
 
M

Mark Lawrence

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.

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

Mark Lawrence
 

Ask a Question

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

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

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,099
Messages
2,570,626
Members
47,237
Latest member
David123

Latest Threads

Top