Beat: Was die RFC dazu sagt

Beitrag lesen

Cookie Path='/cms1folder'
Cookie Path='/cms2folder'
Cookie Path='/'

Meine Frage an die Kenner:
Was ist das vorgeschriebene Verhalten für Cookies, die den gleichen Name haben. Welches der gleichen Cookies darf vom Client an den Server gesendet werden?

  • es werden zwei der drei gesandt
  • es wird das neueste gesandt
  • es wird dasjenige gesandt, das den restriktivsten Pfad hat?

Ich könnte das jetzt recherchieren. Meine Erfahrung mit dem Standard rät mir aber, euch hier auch zu konsultieren.

Stelle mal die relevanten Stellen des Regelwerks zusammen:

A) Wenn kein Pfad gesetzt wird:
Path    Defaults to the path of the request URL that generated the
           Set-Cookie2 response, up to and including the right-most /.
Beispiel 1:
  URI: http://example.org/this/path
resultiert in
  Path: /this/

Beispiel 2:
  URI: http://example.org/this.resource
resultiert in
  Path: /

B) Ein UA darf ein Cookie nicht speichern wenn (unter anderem)
A user agent rejects (SHALL NOT store its information) ... any of the following is true of the attributes explicitly present in the Set-Cookie2 response header:
      *  The value for the Path attribute is not a prefix of the
         request-URI.

Beispiel:
  Request URI: http://example.org/this/file
muss folgende Cookies verwerfen
  Path: /that/
  Path: /that

C) Bestehendes Cookie ersetzen:
3.3.3  Cookie Management  If a user agent receives a Set-Cookie2
   response header whose NAME is the same as that of a cookie it has
   previously stored, the new cookie supersedes the old when: the old
   and new Domain attribute values compare equal, using a case-
   insensitive string-compare; and, the old and new Path attribute
   values string-compare equal (case-sensitive).

Mit anderen Worten. Der Browser wird pro unterschiedliche Pfad angabe ein Cookie speichern. bei gleichlautenden Pfaden aber bestehende Cookies gleichen Domain-Attributs ersetzen.

Diese Beobachtung kann ich für FX bestätigen.

D) Cookies senden
3.3.4  Sending Cookies to the Origin Server  When it sends a request
   to an origin server, the user agent includes a Cookie request header
   if it has stored cookies that are applicable to the request, based on
      * the request-host and request-port;
      * the request-URI;
      * the cookie's age.

Hinweis, der Wert des Pfad-Attributes spielt keine Rolle. Der Browser sendet also theoretisch Alle Cookies für die Domain, die obige Bedingung erfüllen.

Aber es gilt:
The value for the path attribute MUST be the value from the Path attribute, if one was present, of the corresponding Set-Cookie2 response header.  Otherwise the attribute SHOULD be omitted from the Cookie request header.

Dann folgt jedoch:
"Path Selection: The request-URI MUST path-match the Path attribute of the cookie."

Das ist eine unglückliche Formulierung und verwirrend. Das kann bestenfalls heissen, dass
  path /that/
nicht an einen Request auf
  /this
gesendet wird

Laut Standard ist also die Pfadangabe ein Filter auch für das senden der Cookies.

Soweit die Zusammenfassung aus dem Standard.
Die Realität kann etwas anders aussehen.

mfg Beat

--
><o(((°>           ><o(((°>
   <°)))o><                     ><o(((°>o
Der Valigator leibt diese Fische