问题
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
回答1:
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.
来源:https://stackoverflow.com/questions/21226475/difference-between-cookie-and-string-in-request-header