You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@turbine.apache.org by Johnny Quazar <qu...@bitblaster.com> on 2003/02/23 19:13:46 UTC
Re: Strange Cookie problem
Maybe it's about the script name (and thereby the cookie path)? Have
you carefully inspected your cookie cache?
It took me a long time to come up with this, but it works in all
cases that I've found. I'll share it FWIW maybe it will give you some
ideas:
SET:
CookieParser cp = data.getCookies();
DynamicURI dui = new DynamicURI(data, "/");
dui.removePathInfo();
dui.setScriptName("/");
cp.setCookiePath(dui);
cp.set("myCookieName", "myCookieValue", 60*60*24*365);
GET:
CookieParser cp = data.getCookies();
String myCookieValue = cp.getString("myCookieName");
HTH, debugging this sort of thing isn't especially fun :<
At 8:42 PM +0100 2/22/03, Henrik W. Hansen wrote:
>Hi all
>I am having problems setting a cooike on a RedHat 7.3 with tomcat
>4.1.18 and JDK141_01. The thing is, that I am able to read and write
>cookies on the same configuration on a WinXP. The code setting the
>cookie is:
> Cookie userVote = new Cookie("havepolled", "somethingmeaningfull");
> userVote.setPath(data.getRequest().getContextPath());
> userVote.setMaxAge(2592000);
> data.getResponse().addCookie(userVote);
>
>How come the behavior differs?
>
>Any suggestions are welcome!
>
>/Henrik
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: turbine-user-help@jakarta.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-user-help@jakarta.apache.org
Re: Strange Cookie problem
Posted by "Henrik W. Hansen" <sp...@procesgruppen.dk>.
Hi
Thanks for your response. It did not help me though. I am still not
receiving the cookie on Linux when using your code. I am having the
correct behavior when running on Windows!
But I have found out this much. If I try and set the cookie by calling
an action that sets a cookie as the first thing I do when opening the
browser, no cookie is set. But if i log in to jetspeed with a user and
the tries to set the cookie it works fine.
The url from where I am not able to set the cookie is:
http://192.168.1.2:8080/jetspeed/portal or
http://192.168.1.2:8080/jetspeed/index.jsp
From the following url i am able to set the cookie.
http://192.168.1.2:8080/jetspeed/portal/media-type/html/user/a/page/default.psml/template/Home
I recon it must be some Path problem?
To inspect my cookie cache i use Mozillas Cookie Manager, and for IE I
just browse C:\Documents and Settings\username\Cookies
I guess that is the way to incept the cookie cache?
Any ideas why I can not set the cookie from the "root" url ?
Any help would greatly be appreciated.
Best regards
/Henrik
Johnny Quazar wrote:
> Maybe it's about the script name (and thereby the cookie path)? Have
> you carefully inspected your cookie cache?
>
> It took me a long time to come up with this, but it works in all cases
> that I've found. I'll share it FWIW maybe it will give you some ideas:
>
> SET:
> CookieParser cp = data.getCookies();
> DynamicURI dui = new DynamicURI(data, "/");
> dui.removePathInfo();
> dui.setScriptName("/");
> cp.setCookiePath(dui);
> cp.set("myCookieName", "myCookieValue", 60*60*24*365);
>
> GET:
> CookieParser cp = data.getCookies();
> String myCookieValue = cp.getString("myCookieName");
>
> HTH, debugging this sort of thing isn't especially fun :<
>
>
> At 8:42 PM +0100 2/22/03, Henrik W. Hansen wrote:
>
>> Hi all
>> I am having problems setting a cooike on a RedHat 7.3 with tomcat
>> 4.1.18 and JDK141_01. The thing is, that I am able to read and write
>> cookies on the same configuration on a WinXP. The code setting the
>> cookie is:
>> Cookie userVote = new Cookie("havepolled",
>> "somethingmeaningfull");
>> userVote.setPath(data.getRequest().getContextPath());
>> userVote.setMaxAge(2592000);
>> data.getResponse().addCookie(userVote);
>>
>> How come the behavior differs?
>>
>> Any suggestions are welcome!
>>
>> /Henrik
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
>> For additional commands, e-mail: turbine-user-help@jakarta.apache.org
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: turbine-user-help@jakarta.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-user-help@jakarta.apache.org