Cookie is nothing but a small piece of information most of the times a string in the request header send by the client to server. If i add one more string to the request header at server in java like conn.addRequestProperty("iPlanetDirectoryPro", token);
then is there any difference between the two? Can the second one be also considered as a cookie.
Regards,
Maclean Maurice Pinto
HTTP headers are used to pass additional information with HTTP response or HTTP requests. A cookie is an HTTP request header i.e. used in the requests sent by the user to the server. It contains the cookies previously sent by the server using set-cookies. It is an optional header.
The Cookie HTTP request header contains stored HTTP cookies associated with the server (i.e. previously sent by the server with the Set-Cookie header or set in JavaScript using Document. cookie ). The Cookie header is optional and may be omitted if, for example, the browser's privacy settings block cookies.
Cookies are set using the Set-Cookie header field, sent in an HTTP response from the web server. This header field instructs the web browser to store the cookie and send it back in future requests to the server (the browser will ignore this header field if it does not support cookies or has disabled cookies).
You'll want to read the HTTP specification (message headers) and the HTTP State Management specification.
The HTTP specification provides message headers
Each header field consists of a name followed by a colon (":") and the field value.
For example, you could have
Content-Length:42
This is a header.
The HTTP State Management specification defines the Cookie
and Set-Cookie
headers. Those are two specific headers that are used for achieving state in HTTP request and response cycles (HTTP is a stateless protocol).
So
conn.addRequestProperty("iPlanetDirectoryPro", token); then is there any difference between the two?
Yes, there is a big difference. The above is a simple request header. It has nothing to do with a Cookie
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With