Losing cookies after URL is rewritten

23 views
Skip to first unread message

Jim d

unread,
Sep 30, 2009, 8:31:58 PM9/30/09
to UrlRewrite
I'm finding a problem where my cookies are apparently being set to
null I arrive at a page via a rewrite rule. To be clear, I'm not even
sure this a problem with UrlRewriteFilter or my limited understanding
of cookies. Anyway, I'm currently using UrlRewriteFilter 3.2.0 beta
on Tomcat 6.0.18 and my rule appears below:

<rule>
<note>redirect /main to the edit action on tsf pagefilter</
note>
<from>/main/</from>
<to>/servlet/Controller?action=10000&amp;target=500</to>
</rule>

The forward appears to work, but for some reason I'm not receiving any
cookies. For example, when I go to:

http://localhost/myapp/servlet/Controller?action=10000&target=500

Everything works just fine, and when I debug the server side I see my
cookie "appsessionid" being set properly. However, when I go to:

http://localhost/myapp/main/

My cookies aren't being set. When I debug the app I can tell that my
querystring variables ('action' and 'target') are being properly set
but "appsessionid" is does not appear in my cookies collection. It's
very possible that my web browser isn't even sending the cookie, but
either way I don't know why this may be happening. Anybody have any
ideas? Many thanks in advance --Jim d

Avlesh Singh

unread,
Oct 1, 2009, 12:36:26 PM10/1/09
to urlre...@googlegroups.com
Upgrading to the latest version fixed your issue. Right?

Cheers
Avlesh

Jim d

unread,
Oct 1, 2009, 2:33:36 PM10/1/09
to UrlRewrite
Unfortunately not. I'm using the 3.2.0 version currently available
from the front page of http://tuckey.org/urlrewrite/.

It may simply be that the browser isn't sending the cookies in the
request, but I don't think my app is specifying a path scope for the
cookie, so I assume that the client should be passing cookies for all
requests to that app, right? Again, my understanding of cookies is a
bit fuzzy.

Wim De Smet

unread,
Oct 2, 2009, 3:16:02 AM10/2/09
to urlre...@googlegroups.com
Probably, as long as the requests use the same host.

Jim d

unread,
Oct 2, 2009, 4:04:26 AM10/2/09
to UrlRewrite
Turns out I *was* setting a cookie path. Apparently when you add a
new cookie to the servlet response it sets the cookie path to the same
path as the servlet, in this case "/servlet/Controller". If I
explicitly set the cookie path to "/" it seems to work fine.

Anyway, I think I'm fine now. Apologies for the false alarm, but I
appreciate the help!
Reply all
Reply to author
Forward
0 new messages