Is there any advantage of using set-cookie2 over set-cookie. And is there any difference in how they affect the functionality on server and client side.
Cookies are strings of data that a web server sends to the browser. When a browser requests an object from the same domain in the future, the browser will send the same string of data back to the origin server. The data is sent from the web server in the form of an HTTP header called "Set-Cookie".
Set-Cookie2 allowed you to restrict your cookie to a list of ports to which the cookie may be sent. According to RFC2965: The Port attribute restricts the port to which a cookie may be returned in a Cookie request header.
Set-Cookie is a forbidden response header name. You cannot read it using browser-side JavaScript. If you need to pass that information to your JavaScript, then you need to have the server use some other mechanism (such as a different header or part of the response body).
Cookies are small pieces of text sent to your browser by a website you visit. They help that website remember information about your visit, which can both make it easier to visit the site again and make the site more useful to you.
Set-Cookie2 isn't widely implemented and now deprecated.
See RFC 6265.
First of all Set-Cookie2 is deprecated as of RFC6265 and should not be used. But as for the differences between Set-Cookie and Set-Cookie2:
Set-Cookie2 allowed you to restrict your cookie to a list of ports to which the cookie may be sent. According to RFC2965:
The Port attribute restricts the port to which a cookie may be returned in a Cookie request header. Note that the syntax REQUIREs quotes around the OPTIONAL portlist even if there is only one portnum in portlist.
There are three possible behaviors, depending on the Port attribute in the Set-Cookie2 response header:
By default (no Port attribute), the cookie MAY be sent to any port.
If the attribute is present but has no value (e.g., Port), the cookie MUST only be sent to the request-port it was received from.
If the attribute has a port-list, the cookie MUST only be returned if the new request-port is one of those listed in port-list.
This differs because Set-Cookie does not allow you to restrict cookies to any specific ports. Therefore your cookies are sent to any port on that host no matter the port number.
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