kevin
kevin

Reputation: 43

why my chrome did not send the cookie i set

My problem is as the title , and I programmed with Java, following is my code

Cookie cookie = new Cookie("shikaiwenCookie","sended");
cookie.setMaxAge(2000);
cookie.setDomain("/bbs");

enter image description here

this is the information I get from my HTTP monitor. It seems that cookie has been send to the browser. But when I submit my form, the browser did not send the cookie to my server. Could someone help me ? Thanks in advance .

Upvotes: 0

Views: 155

Answers (1)

ljgw
ljgw

Reputation: 2771

I think you are confusing domain with path. Try setPath("/bbs").

edit:

both the domain and path are used to determine if the cookie is relevant for the request. The domain focusses on the domainname in the URL, and the path must path-match with the path of the url. As an example: the url http://stackoverflow.com/posts/19489484 has domain stackoverflow.com and path /posts/19489484. Here the cookie path /posts would path-match with the path in the url.

Upvotes: 1

Related Questions