You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Audrius Peseckis <au...@ivs.lt> on 2006/06/30 15:06:10 UTC

How to set cookie ftom T4 application for different host

Hello,

we have a problem when setting cookie value for a different host. When using standard T4 CookieSource we can set a cookie for our application on application's host. But we need to set a cookie for a different host. I suppose it's done with injection of tapestry.globals.HttpServletResponse.

There's a piece of our code that is not working:

Cookie c1 = new Cookie("cookieName", "cookieValue");
  
c1.setDomain("hostname");
c1.setPath("/session_test");
c1.setMaxAge(999999);
  
this.getB().addCookie(c1); // B is declared as <inject object="service:tapestry.globals.HttpServletResponse" property="b" />

We are trying to set cookie in pageBeginRender method.

Any help is appreciated.

Audrius

Re: How to set cookie ftom T4 application for different host

Posted by Phillip Rhodes <sp...@rhoderunner.com>.
Third party cookies (cookies from other hosts) are not accepted by default.
I have got around this problem 2 different ways:

For machines in same domain:
1) use the cookie.setDomain(".authsum.org") method to create a cookie that
can be read by all hosts your domain.

For machines in different domains:
2) Put the cookie value into the url, and have a filter in your tapestry
application that reads the cookie value from the uri, and writes a cookie
with the parameter value so you no longer have to do url re-writing.

I had to deal with these issues with authsum...  It's a tapestry based
sso,registration,authorization server, when you have sso with many
different tomcat instances, a global domain sso cookie is the way to go.



> Hello,
>
> we have a problem when setting cookie value for a different host. When
> using standard T4 CookieSource we can set a cookie for our application on
> application's host. But we need to set a cookie for a different host. I
> suppose it's done with injection of tapestry.globals.HttpServletResponse.
>
> There's a piece of our code that is not working:
>
> Cookie c1 = new Cookie("cookieName", "cookieValue");
>
> c1.setDomain("hostname");
> c1.setPath("/session_test");
> c1.setMaxAge(999999);
>
> this.getB().addCookie(c1); // B is declared as <inject
> object="service:tapestry.globals.HttpServletResponse" property="b" />
>
> We are trying to set cookie in pageBeginRender method.
>
> Any help is appreciated.
>
> Audrius
>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


RE: How to set cookie ftom T4 application for different host

Posted by Steve Shucker <ss...@vmsinfo.com>.
The cookie domain must be a domain, not a host.  For a cookie at
"tapestry.apache.org", the domain is "apache.org" and will be valid for
"tomcat.apache.org" as well.  If you don't have at least one period in the
hostname, the cookie just isn't set.  Personally, I have a small bit of
logic to detect if my app is running on localhost (development) and not set
the cookie domain.  Otherwise, it gets set to my company's domain.

-Steve

-----Original Message-----
From: Audrius Peseckis [mailto:audrius@ivs.lt] 
Sent: Friday, June 30, 2006 6:06 AM
To: Tapestry users
Subject: How to set cookie ftom T4 application for different host

Hello,

we have a problem when setting cookie value for a different host. When using
standard T4 CookieSource we can set a cookie for our application on
application's host. But we need to set a cookie for a different host. I
suppose it's done with injection of tapestry.globals.HttpServletResponse.

There's a piece of our code that is not working:

Cookie c1 = new Cookie("cookieName", "cookieValue");
  
c1.setDomain("hostname");
c1.setPath("/session_test");
c1.setMaxAge(999999);
  
this.getB().addCookie(c1); // B is declared as <inject
object="service:tapestry.globals.HttpServletResponse" property="b" />

We are trying to set cookie in pageBeginRender method.

Any help is appreciated.

Audrius


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org