Practise, Case Studying, and Caveats#
Duplicate Cookie Name Problem#
Above we have stated that cookie name in itself is not distinctive, but rather a member of 3 element group that determines a distinctive cookie entry. We have also shown that with domain scoping there are 2 parts to a domain name – fixed-domain and scoped-domain, which obscures the domain declaration and results in multiple cookie entries that can later be fetched by a single domain declaration. What is more, we have proven that intuitively similar paths (eg. /dir
or /dir/
) do not cancel each other out, and can also result in multiple cookie entries which can later on be fetched for a single path query.
Let’s assume that our working URL is https://www.domain.com/dir/
.
Set-Cookie: foo=one
Set-Cookie: foo=two; Domain=.domain.com
Set-Cookie: foo=three; Domain=www.domain.com
Set-Cookie: foo=four; Path=/
Set-Cookie: foo=five; Path=/dir/
Set-Cookie: foo=six; Domain=.domain.com; Path=/
Set-Cookie: foo=seven; Domain=.domain.com; Path=/dir/
The response would be the following.
Cookie: foo=five; foo=seven; foo=one; foo=two; foo=three; foo=four; foo=six
The resulting data store.
The data store is sorted by path column in string length descending order, and time entered ascending order.
Let’s see how browsers cope with this issue.
< Set-Cookie: foo=bar
< Set-Cookie: foo=baz
foo=baz
array(1) { ["foo"]=> string(3) "baz" }
foo=baz
array(1) { ["foo"]=> string(3) "baz" }
foo=baz
array(1) { ["foo"]=> string(3) "baz" }
foo=baz
array(1) { ["foo"]=> string(3) "baz" }
Case Study for Setting and Matching Domain Name#
Working site address: https://www.domain.com/
(mind the “www” prefix).
Working site address: https://domain.com/
(mind no “www” prefix).
Working site address: https://domain.com./
(mind no “www” prefix, and a trailing dot in the host component).
Other Case Studies and Caveats#
< Set-Cookie: foo=ba=r
foo=ba=r
array(1) { ["foo"]=> string(4) "ba=r" }
foo=ba=r
array(1) { ["foo"]=> string(4) "ba=r" }
foo=ba=r
array(1) { ["foo"]=> string(4) "ba=r" }
foo=ba=r
array(1) { ["foo"]=> string(4) "ba=r" }
< Set-Cookie: foo=ba r
foo=ba r
array(1) { ["foo"]=> string(4) "ba r" }
foo=ba r
array(1) { ["foo"]=> string(4) "ba r" }
foo=ba r
array(1) { ["foo"]=> string(4) "ba r" }
foo=ba r
array(1) { ["foo"]=> string(4) "ba r" }
< Set-Cookie: foo="ba r"
foo="ba r"
array(1) { ["foo"]=> string(6) ""ba r"" }
foo="ba r"
array(1) { ["foo"]=> string(6) ""ba r"" }
foo="ba r"
array(1) { ["foo"]=> string(6) ""ba r"" }
foo="ba r"
array(1) { ["foo"]=> string(6) ""ba r"" }
< Set-Cookie: f oo=bar
f oo=bar
array(1) { ["f_oo"]=> string(3) "bar" }
f oo=bar
array(1) { ["f_oo"]=> string(3) "bar" }
f oo=bar
array(1) { ["f_oo"]=> string(3) "bar" }
f oo=bar
array(1) { ["f_oo"]=> string(3) "bar" }
< Set-Cookie: foo="bar"
foo="bar"
array(1) { ["foo"]=> string(5) ""bar"" }
foo="bar"
array(1) { ["foo"]=> string(5) ""bar"" }
foo="bar"
array(1) { ["foo"]=> string(5) ""bar"" }
foo="bar"
array(1) { ["foo"]=> string(5) ""bar"" }
< Set-Cookie: foo=ba;r
foo=ba
array(1) { ["foo"]=> string(2) "ba" }
foo=ba
array(1) { ["foo"]=> string(2) "ba" }
foo=ba
array(1) { ["foo"]=> string(2) "ba" }
foo=ba
array(1) { ["foo"]=> string(2) "ba" }
< Set-Cookie: foo="ba;r"
foo="ba
array(1) { ["foo"]=> string(3) ""ba" }
foo="ba;r"
array(2) { ["foo"]=> string(3) ""ba" ["r""]=> string(0) "" }
foo="ba
array(1) { ["foo"]=> string(3) ""ba" }
foo="ba
array(1) { ["foo"]=> string(3) ""ba" }
< Set-Cookie: foo=ba;r; Path=/my/path
foo=ba
array(1) { ["foo"]=> string(2) "ba" }
foo=ba
array(1) { ["foo"]=> string(2) "ba" }
foo=ba
array(1) { ["foo"]=> string(2) "ba" }
foo=ba
array(1) { ["foo"]=> string(2) "ba" }
< Set-Cookie: foo=bar; Path=/my/path; Dummy
foo=bar
array(1) { ["foo"]=> string(3) "bar" }
foo=bar
array(1) { ["foo"]=> string(3) "bar" }
foo=bar
array(1) { ["foo"]=> string(3) "bar" }
foo=bar
array(1) { ["foo"]=> string(3) "bar" }
< Set-Cookie: foo=bar; Dummy; Path=/my/path
foo=bar
array(1) { ["foo"]=> string(3) "bar" }
foo=bar
array(1) { ["foo"]=> string(3) "bar" }
foo=bar
array(1) { ["foo"]=> string(3) "bar" }
foo=bar
array(1) { ["foo"]=> string(3) "bar" }