GWT store cookie for different domain
I'm using GWT, and I'm trying to set a cookie on the client using com.google.gwt.user.client.Cookies
. If I want to set a cookie using the default domain (for devmode this is 127.0.0.1) it works as expected. I'm using Firebug+Firecookie to look at the cookies in the browser. But if I try to use a different domain, I do not see any cookie show up in Firebug. Specifically:
This works:
Cookies.setCook开发者_如何学Pythonie("name", "xyz");
This does not work:
Cookies.setCookie("name", "xyz", null, "traviswebb.com", "/", false);
EDIT : The documentation for this function call is here: http://google-web-toolkit.googlecode.com/svn/javadoc/1.5/com/google/gwt/user/client/Cookies.html#setCookie%28java.lang.String,%20java.lang.String,%20java.util.Date,%20java.lang.String,%20java.lang.String,%20boolean%29
This isn't related to GWT but to cookies : you simply can't set a cookie for another domain than the one your page is served from. Otherwise malicious people would be able to change cookies for gmail, hotmail, any service.
To complete the answer : you can set cookies for subdomains. Aka, if you're on example.com you can set/get a cookie for test.example.com
精彩评论