Note that you're calling
setDomain
incorrectly in the first example - this field of the cookie takes a domain name and not a full URL. So the call should look like this:cookie.setDomain("localhost");
As the other answer notes, some browsers ignore cookies for
localhost
, so you may want to not set this field of the cookie at all - this has the effect of setting a cookie that will only be returned to the same host that set it (which most of the time is what you want).
No comments:
Post a Comment