Coldfusion cfscript cookie不允许空白到期

Coldfusion cfscript cookie不允许空白到期,第1张

概述我正在尝试在CF10中使用cfscript cookie来设置一个cookie,当浏览器关闭时应该删除它.我可以通过set-header或< cfcookie>来完成,但无法通过struct cookie方法完成. 有没有人知道比使用set-header更好的解决方法? (留在cfscript标签内) <cfscript> // Set-Cookie:TEST1=hello; Expire 我正在尝试在CF10中使用cfscript cookie来设置一个cookie,当浏览器关闭时应该删除它.我可以通过set-header或< cfcookie>来完成,但无法通过struct cookie方法完成.

有没有人知道比使用set-header更好的解决方法? (留在cfscript标签内)

<cfscript>    // Set-cookie:TEST1=hello; Expires=Sun,07-Aug-2044 17:51:26 GMT; Path=/; httpOnly    cookie.test1 = {value="hello",httponly=true};    // Set-cookie:TEST3=hello; Expires=Thu,01-Jan-1970 00:00:10 GMT; Path=/; httpOnly    cookie.test3 = {value="hello",httponly=true,expires="0"};    // Set-cookie:TEST4=hello; Expires=Thu,01-Jan-1970 00:00:10 GMT; Path=/; httpOnly    cookie.test4 = {value="hello",expires="-1"};    // this throws an exception    //cookie.test5 = {value="hello",expires=""};</cfscript><!--- Set-cookie:TEST2=hello2; Path=/; httpOnly ---><cfcookie name="test2" value="hello2" httponly="true">
解决方法 我假设您在测试应用程序时使用的是Chrome或firefox.
我最近遇到了同样的问题. Chrome会保留会话cookie,如果您已从我停止设置的选项中启用了继续 *** 作.这个案例与firefox类似.我没有在IE上测试它,所以我不能说它的行为. Expires属性在这些情况下不起作用.
解决方法是您可以使用max-age属性.您可以在max-age属性中为cookie提供生存时间.
它可以在Chrome和firefox中使用. IE将max-age属性视为未设置的expires属性.所以它会在浏览器重启时清除cookie.我没有在Safari上测试它.
供参考: cookie does not expire in firefox

cookie does not expire in chrome

总结

以上是内存溢出为你收集整理的Coldfusion cfscript cookie不允许空白到期全部内容,希望文章能够帮你解决Coldfusion cfscript cookie不允许空白到期所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/web/1055463.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-25
下一篇 2022-05-25

发表评论

登录后才能评论

评论列表(0条)

保存