Question

we all know that a string is the request header is different from cookie. Now I am trying to send a cookie to server using URL connect. As you know there is no property like set cookie in URL connect, i am using addRequestProperty("iPlanetDirectoryPro", iPlanetDirectoryPro); Now will this be a cookie or a string the request header?

Now at server side if i add request.getCookies(); I will not get any cookies. But if i do request.getHeader("iPlanetDirectoryPro") then i will get my string. So how can i send the cookie?

Was it helpful?

Solution

You need to do is to examine following details of the cookies that are not being sent such as cookie's domain,path, port and 'secure' flag.

Cookies are like temporary storage of data on client side. browser put cookies in his temp directory and send these with each request .

But headers are hints to browser and server . to prepare himself . like content type header it tells that the request is sending data of that particular type like application/json will send json data now server will decide whether it can handle this(type) or not if it can not it will raise an exception.

Refer this for understanding cookies : https://studio.tellme.com/vxml2/ovw/cookies.html

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top