Re: [http-state] Ticket 5: Cookie ordering

"Yngve Nysaeter Pettersen" <> Fri, 05 February 2010 12:56 UTC

Return-Path: <>
Received: from localhost (localhost []) by (Postfix) with ESMTP id EF8033A6D78 for <>; Fri, 5 Feb 2010 04:56:24 -0800 (PST)
X-Virus-Scanned: amavisd-new at
X-Spam-Flag: NO
X-Spam-Score: -6.299
X-Spam-Status: No, score=-6.299 tagged_above=-999 required=5 tests=[AWL=-0.300, BAYES_00=-2.599, J_CHICKENPOX_83=0.6, RCVD_IN_DNSWL_MED=-4]
Received: from ([]) by localhost ( []) (amavisd-new, port 10024) with ESMTP id AsbI90bkbjzB for <>; Fri, 5 Feb 2010 04:56:24 -0800 (PST)
Received: from ( []) by (Postfix) with ESMTP id 94D333A6D6B for <>; Fri, 5 Feb 2010 04:56:23 -0800 (PST)
Received: from killashandra.oslo.osa ( []) by (8.14.3/8.14.3/Debian-5) with ESMTP id o15CrFBO014709 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT); Fri, 5 Feb 2010 12:53:16 GMT
Content-Type: text/plain; charset=iso-8859-15; format=flowed; delsp=yes
To: "Daniel Stenberg" <>
References: <> <op.u7mkruzjvqd7e2@killashandra.oslo.osa> <>
Date: Fri, 05 Feb 2010 13:56:58 +0100
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
From: "Yngve Nysaeter Pettersen" <>
Organization: Opera Software
Message-ID: <op.u7nnk8uyvqd7e2@killashandra.oslo.osa>
In-Reply-To: <>
User-Agent: Opera Mail/10.10 (Win32)
Cc: http-state <>
Subject: Re: [http-state] Ticket 5: Cookie ordering
X-Mailman-Version: 2.1.9
Precedence: list
List-Id: Discuss HTTP State Management Mechanism <>
List-Unsubscribe: <>, <>
List-Archive: <>
List-Post: <>
List-Help: <>
List-Subscribe: <>, <>
X-List-Received-Date: Fri, 05 Feb 2010 12:56:25 -0000

On Fri, 05 Feb 2010 10:59:09 +0100, Daniel Stenberg <> wrote:

>> AFAIK it will not be possible to define an inter-operable domain  
>> ordering specification, so instead the specfication should say that  
>> servers must not rely on a specific ordering for cookies with the same  
>> name set for different domains and the same path (The path  
>> specification means that it is perhaps possible to rely on it for same  
>> name cookies with different name, even for different domains).
> Not only that. Your way even makes sure servers can't unconditionally  
> assume the order of cookies with different path lengths, as they must  
> first take into account if the cookies have different domains or not.
> I think the spec need to say something about this, if nothing else in an  
> explanatory way as to why or how different clients may send cookies.
> All this cookie ordering taken into account, I think a wise  
> recommendation in the spec might be to just advice that cookies using  
> the same name with different paths or domains are simply not a good idea  
> to use at all if you want to inter-operate.

There is also the issue that if ordering, even at the domain level is not  
specified, then there will be problems if a server treats ordering as  
significant, such as only checking the first cookie with the name it is  
looking for.

If we call this server, and assumes it is looking for and  
sets the cookie MyCookie=bar for the host itself (no domain), and we also  
have a server that sets MyCookie=foo for the domain the following can occur if ordering is that first received  
cookie is first in line

If the client visits first, then, order by  
creation date will produce the MyCookie sequence "bar, foo", if is visited first then the sequence will be "foo, bar". In  
the latter case will not find its cookie, and may  
repeatedly try to set it. Any update of the cookie (unless original  
creation date is preserved) will move the newest cookie to the last  
position in the list.

If the ordering is most recently set/updated the sequences would be  
reversed (bar first gives "foo, bar", foo first gives "bar, foo"), and the  
bar server would run into problems on the first access after the client  
visited foo, but that would be fixed with sending a new cookie, but the  
session would be lost.

In Opera the sequence would always be "bar,foo" since the foo cookie is  
set for the parent domain which is listed later.

IOW, if ordering is determined by anything but the domain and path the  
sequence of cookie is going to vary depending on which servers the clients  
visits and the sequence it visits them, and this might cause significant  
problems for a server that considers ordering significant.

Yngve N. Pettersen
Senior Developer		     Email:
Opera Software ASA         
Phone:  +47 24 16 42 60              Fax:    +47 24 16 40 01