Czy w żądaniu HTTP jest dozwolone wiele nagłówków plików Cookie?

Pliki cookies zazwyczaj zawierają nazwę strony internetowej, z której pochodzą, czas przechowywania ich na urządzeniu końcowym oraz unikalny numer.]}

Cookie: a=1; b=2

Czy standard pozwala wysyłać je jako oddzielne nagłówki, takie jak:

Cookie: a=1
Cookie: b=2
Czy zawsze muszą być na tej samej linii?
Author: Benjamin, 2013-04-30

2 answers

Przejrzałem tę stronę, szukając szczegółów na ten temat. Cytat z HTTP State Management Mechanism, RFC 6265 powinno być jaśniej:

5.4. Nagłówek Cookie

Gdy agent użytkownika generuje żądanie HTTP, agent użytkownika musi Nie załączyć więcej niż jednego pola nagłówka pliku Cookie.

Wygląda na to, że używanie wielu Cookie nagłówków jest w rzeczywistości zabronione!

 105
Author: James Chong,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2018-07-12 22:39:40

Jest teraz dozwolone w HTTP / 2 (RFC 7540), który określa:

    8.1.2.5.  Compressing the Cookie Header Field

   The Cookie header field [COOKIE] uses a semi-colon (";") to delimit
   cookie-pairs (or "crumbs").  This header field doesn't follow the
   list construction rules in HTTP (see [RFC7230], Section 3.2.2), which
   prevents cookie-pairs from being separated into different name-value
   pairs.  This can significantly reduce compression efficiency as
   individual cookie-pairs are updated.

   To allow for better compression efficiency, the Cookie header field
   MAY be split into separate header fields, each with one or more
   cookie-pairs.  If there are multiple Cookie header fields after
   decompression, these MUST be concatenated into a single octet string
   using the two-octet delimiter of 0x3B, 0x20 (the ASCII string "; ")
   before being passed into a non-HTTP/2 context, such as an HTTP/1.1
   connection, or a generic HTTP server application.

   Therefore, the following two lists of Cookie header fields are
   semantically equivalent.

     cookie: a=b; c=d; e=f

     cookie: a=b
     cookie: c=d
     cookie: e=f
 5
Author: wusatosi,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2018-07-12 20:51:58