Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Cookie question

 
B Mistry
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

I have some problems regarding the cookie.

I am setting a cookie in the server code as:

name: name:value
path: "/"

When i send an http request, I see that the cookie is received in the response but for all consecutive requests the browser should send the same cookie in the http request right ? I see that the cookie is not sent to the server.

I don't think there is a control in the browser which enables or disables the cookie which is sent in the request.. please correct me if i am wrong.

So my question is, how do I make the browser send the cookie in the request which was previously received and set into the cookie repository??

Thanks in advance.
 
elvadas nono
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Guy Can you post a piece of code?
You set a cookie in the HttpResponse instance using response.addCookie(Cookie cookie);
and the cookie has a set of fields like name,value,comments.
Cookies are sent from the client to the server for each requestt as key name pair name/value, fields like comments are not sent to the servers.
first of all ensure that you fill the cookie properly.
In further, cookies which has the property httpOnly set to true are not exposed to client side scripting.
so you can transfered them to servers only by an HTTP request.

 
B Mistry
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
elvadas nono wrote:Hi Guy Can you post a piece of code?
You set a cookie in the HttpResponse instance using response.addCookie(Cookie cookie);
and the cookie has a set of fields like name,value,comments.
Cookies are sent from the client to the server for each requestt as key name pair name/value, fields like comments are not sent to the servers.
first of all ensure that you fill the cookie properly.
In further, cookies which has the property httpOnly set to true are not exposed to client side scripting.
so you can transfered them to servers only by an HTTP request.



elvadas,

I figured it out. I was using the ip address in the url instead of full hostname and that was the problem. All my consecutive requests were not picking up the cookie from the browser repository but now its ok.

Thanks for your response.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic