Cookie不会在IE中续订/覆盖

dec*_*eze 9 cookies internet-explorer cakephp http-headers

我在IE中有一个奇怪的奇怪怪癖.当用户登录到站点时,我正在生成新的会话ID,因此需要覆盖cookie.流程基本上是:

  1. 客户端转到https://secure.example.com/users/login页面,自动接收会话ID
  2. 客户端将登录凭据POST到同一地址
  3. 客户端收到以下set-cookie标头以及302重定向到https://secure.example.com/users/mypage:

    的CakePHP =删除; expires = Sun,05-Apr-2009 04:50:35 GMT; path =/
    CAKEPHP = 98hnIO23 ......; 到期=周一,2010年4月12日04:50:36 GMT; 路径= /; 安全

  4. 客户端应该访问https://secure.example.com/users/mypage,显示新的会话ID.

这适用于除IE之外的所有浏览器(在7和8中测试).IE保留旧的,未经身份验证的会话ID,并重定向回登录页面.它适用于我的本地测试环境(使用自签名证书https://localhost:8443/...),但不适用于实时服务器.

我正在使用CakePHP并只发出一个$this->Session->renew()产生上述cookie头的a.

任何想法如何让IE接受新的cookie?


这是完整的标题:

HTTP/1.0 302 Moved Temporarily
Date: Thu, 08 Apr 2010 02:54:30 GMT
Server: Apache
Expires: Mon, 26 Jul 1997 05:00:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma: no-cache
P3P: CP="NOI ADM DEV PSAi COM NAV OUR OTRo STP IND DEM"
Set-Cookie: CAKEPHP=deleted; expires=Wed, 08-Apr-2009 02:54:30 GMT; path=/
Set-Cookie: CAKEPHP=d55c...; expires=Thu, 15 Apr 2010 02:54:31 GMT; path=/; secure
Last-Modified: Thu, 08 Apr 2010 02:54:30 GMT
Location: https://secure.example.com/users/mypage
Vary: Accept-Encoding
Content-Length: 0
Connection: close
Content-Type: text/html; charset=utf-8
Run Code Online (Sandbox Code Playgroud)

我想我发现了问题:IE发送两个名称相同的cookie.这是服务器的下一个请求:

GET /users/mypage HTTP/1.1
Accept: image/gif, image/jpeg, image/pjpeg, image/pjpeg, application/x-shockwave-flash, application/x-silverlight, */ *
Referer: https://secure.example.com/users/login
Accept-Language: en-gb
User-Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; .NET CLR 1.1.4322)
Accept-Encoding: gzip, deflate
Host: secure.example.com
Connection: Keep-Alive
Cache-Control: no-cache
Cookie: CAKEPHP=19c6...; CAKEPHP=d55c...
Run Code Online (Sandbox Code Playgroud)

请注意,它会发送两个cookie,即登录后收到的cookie,还有旧的cookie.它收到了主页上的旧页面example.com,设置为path=/.它也发送请求secure.example.com.它不会被上面的标题取代,而是将其添加为额外的cookie.我怎么能阻止它呢?

egl*_*ius 3

确保为您的基域发出 cookie。

这很可能是问题所在,因为这种行为在不同的浏览器中肯定有所不同。

我还没有在 cakephp 中完成,但这应该可以