2012-05-09 30 views
0

怪怪所以下面的代码工作完全在FirefoxCFcookie在不同的浏览器

<!--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

+1

这是很多饼干。你有没有想过使用localStorage? –

回答

1

我认为您有一个加载问题 - 在最终确定cookie操作之前浏览器已重定向。将你的location.href改为一个cflocation,或者把它放在body“onLoad()”事件中(或者使用jquery的load事件来处理浏览器重定向的细微差别)。

+0

像魅力一样工作谢谢你。 :) –

+1

太棒了!乐意效劳。 –

1

该代码对我来说很合适。我在这里运行它,使用cookie名称作为cookie值,例如并且cookie在IE和Chrome中正确设置并通过了。 Cookie规范中有一些漏洞(当天由Netscape编写)导致某些浏览器在某些情况下做了些微不同的事情。 我推荐2件事:

1)简化发送的值。在我的情况下,我使用cookie名称作为cookie值,它似乎工作。我会做同样的测试,只是在picChoice.cfm中的cfdump#cookie#(这就是我在我的测试页这里所做的)

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