0

所以下面的代码在 Firefox 中完美运行

<!--Cookies-->
<cfset timer = createTimeSpan(0,3,0,0)>
<cfcookie name = "user.ID" value = "#userID#" expires="#timer#">               <!--this will expire in three hours -->
<cfcookie name = "user.Site" value = "#userSite#" expires="#timer#">
<cfcookie name = "user.Sess" value = "#userSess#" expires="#timer#">
<cfcookie name = "user.FName" value = "#userFName#" expires="#timer#">
<cfcookie name = "user.LName" value = "#userLName#" expires="#timer#">
<cfcookie name = "user.Email" value = "#userEmail#" expires="#timer#">
<cfcookie name = "user.SiteFirst" value = "#userSiteFirst#" expires="#timer#">
<cfcookie name = "user.RoundsTotal" value = "#userRoundsTotal#" expires="#timer#">
<cfcookie name = "user.RoundsCurrent" value = "#userRoundsCurrent#" expires="#timer#">

<!-- And now we send the user off to wait.cfm where they will wait --->
<!-- Users will not head to choose their picture choice --->

<script type="text/javascript">
    location.href='picChoice.cfm';
</script>

在 Firefox 中,所有 cookie 中的值都可以完美传递。任何其他浏览器,所有 cookie 均为空。

希望有人能在我看不到的地方看到错误。如果您想查看完整的 cfm,可以在此处进行:http: //pastebin.com/4G4wvjLd

4

2 回答 2

1

我认为你有一个负载问题 - 在完成 cookie 操作之前重定向浏览器。将您的 location.href 更改为 cflocation 或将其放入主体“onLoad()”事件中(或使用 jquery 的 load 事件来处理浏览器重定向的细微差别)。

于 2012-05-09T21:57:41.620 回答
1

代码对我来说看起来不错。我在这里运行它,使用 cookie 名称作为 cookie 值,例如,cookie 已正确设置并在 IE 和 Chrome 中通过 OK。Cookie 规范(由 Netscape 早先编写)中存在一些漏洞,导致某些浏览器在某些情况下做的事情略有不同。我推荐两件事:

1) 简化正在发送的值。就我而言,我使用 cookie 名称作为 cookie 值,它似乎可以工作。我会做与测试相同的操作,只需在 picChoice.cfm 中执行 cfdump #cookie#(这就是我在此处的测试页面中所做的)

2) 使用 fiddler 作为代理运行请求并观察浏览器获取和发送的内容,以确保您的代码确实发送了 set-cookie 标头并查看浏览器发送回服务器的内容。

于 2012-05-10T10:48:59.117 回答