Is there a best practice whether to set a slash at the end of a cookie path?
Is
path
better than
path/
in any way?
I found out that both versions result in different cookies, but I don't know which version is preferred.
As far as the server-side goes, this issue (https://bugzilla.mozilla.org/show_bug.cgi?id=469678) states:
Per RFC 2109 the default path of a cookie when set by Set-Cookie is:
Defaults to the path of the request URL that generated the Set-Cookie response, up to, but not including, the right-most /.
So this is one perspective where a trailing slash should not be used.
https://www.rfc-editor.org/rfc/rfc2109
DON'T include trailing '/'.
Obsoletes: 2109
https://www.rfc-editor.org/rfc/rfc2965
DO include trailing '/'.
Obsoletes: 2965
https://www.rfc-editor.org/rfc/rfc6265#section-5.2.4
DON'T include trailing '/'.
On the client, if you use the following code:
document.cookie="a=1"
you get these results from inspecting devtools for each browser (my site had a window.location.pathname="/selenium/tests/testCustomizeColumnsPage.html")
Chrome/71.0.3578 /selenium/tests
Firefox/64.0 /selenium/tests/
Edge /selenium/tests/
IE11 devtools doesn't show cookies, think the path includes the trailing '/'
So is Chrome wrong here?
Other references:
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