Welcome to WebmasterWorld Guest from 3.92.92.168

Forum Moderators: Ocean10000 & phranque

Message Too Old, No Replies

mod_rewrite ate my cookie!

More info about a problem I had in Jan, not solved yet

     
3:20 pm on Jun 23, 2003 (gmt 0)

New User

10+ Year Member

joined:Jan 7, 2003
posts:10
votes: 0


I have an Apache 2 module which serves up all my pages. It uses a temporary cookie to hold a session ID (so it's not in the URL - nice).

I use mod_rewrite to forward url requests to the module:

# the content module

LoadModule BoldRetina_module modules/mod_BoldRetina.so

<Location /TDBoldRetina >
SetHandler mod_boldretina-handler
</Location>

RewriteEngine On

# all rules here turned off and ommitted for clarity

# insert TDBoldRetina in front of everything that's left

RewriteRule ^(.*)$ /TDBoldRetina$1 [QSA,PT,L]

If I disable this rule and make internal urls look like
//domain/TDBoldRetina/stuff
then it works.

If I enable this rule and make internal urls look like
//domain/stuff
then it gives me a new session ID with every refresh, so it's not getting the cookie for some reason.

Any ideas as to why?
Any ideas as to how I can view the temporary cookie in a browser to be sure it's getting to the browser?

Bryan

3:30 pm on June 23, 2003 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Aug 10, 2001
posts:1551
votes: 10


What path are your cookies valid for?

It could be that your module creates cookies that are valid for "/TDBoldRetina". Since the browser doesn't see this path component in the URL, it won't return the cookie in this case.

Do you really need the PT flag?

3:32 pm on June 23, 2003 (gmt 0)

New User

10+ Year Member

joined:Jan 7, 2003
posts:10
votes: 0


I don't know what path the cookies are valid for. Would the module know what its Apache Location is to be able to restrict the path?

I use the PT flag so that the URL gets passed to the content generation module mod_BoldRetina. Is that correct?

Bryan

4:05 pm on June 23, 2003 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Aug 10, 2001
posts:1551
votes: 10


I don't know what path the cookies are valid for. Would the module know what its Apache Location is to be able to restrict the path?

A decent browser should be able to show you the contents of each cookie it has currently stored. At least Mozilla does that... ;) I have a little script here to analyze the communication between client and server, but there might even be some online tools around to do that. I think Brett uses the Proxomitron filtering proxy for the same purpose.

I use the PT flag so that the URL gets passed to the content generation module mod_BoldRetina. Is that correct?

To be honest, I'm not completely sure. Looking through the mod-rewrite docs a few minutes ago, it almost seemed as if it was the other way round (eg. PT makes your module see the *rewritten* path). You'd have to instrument your module to dump this information somehow to be sure, which will help debug the problem in any case.

4:19 pm on June 23, 2003 (gmt 0)

New User

10+ Year Member

joined:Jan 7, 2003
posts:10
votes: 0


> PT makes your module see the *rewritten* path

OK - that's what I want. Thought it was correct.

> A decent browser should be able to show you the
> contents of each cookie it has currently stored

But is a temporary cookie ever stored?

Bryan

4:25 pm on June 23, 2003 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Aug 10, 2001
posts:1551
votes: 10


> PT makes your module see the *rewritten* path

OK - that's what I want. Thought it was correct.

Whether that's "correct" is up to you to decide depending on your requirements. Of course, I'd assume that your module already knows that it has been called to handle the current request, so seeing the rewritten path might actually confuse it. But that's just speculation, as I have no information on what happens in there.

But is a temporary cookie ever stored?

Not on disk, but the browser still needs to remember it as long as it is running. And if it has the cookie in memory, then it can display it to you for review. Maybe someone who uses IE can jump in and say whether/where this information can be found there. With Mozilla, the cookie manager is in the "Tools" menu.