Coldfusion StructDelete creates blank value

末鹿安然 提交于 2020-01-04 04:06:08

问题


I'm using Codlfusion 9's StructDelete() method to remove a value from a cookie. But after using

StructDelete(cookie,"selector12")

I'm getting a value of [empty string] for cookie.selector12 despite deleting it

This is the code I'm using:

<cfdump var="#cookie#">
<!--- kill any existing selector cookie when looking at a profile --->
<cfset structDelete(cookie,'selector#URL.clk#')>
<cfdump var="selector#URL.clk#">
<cfdump var="#cookie#">

To give the following output:

Does StructDelete actually just set blank values? Or have I missed something obvious and simple... again


回答1:


The behavior of StructDelete() when applied to the COOKIE structure pushes the following header to your browser:

Set-Cookie SELECTOR12=;expires=Wed, 14-Dec-2011 10:06:02 GMT;path=/

which in turn will (for the remainder of the life of that request) produce a browser cookie with a blank value -- which mimics the behavior you're seeing when calling cfdump on that COOKIE structure.

This is simply a side-effect of dealing with the COOKIE structure, which in reality, wraps access to your browser's cookies--and is therefore limited by how cookies are defined/managed in web-browsers.



来源:https://stackoverflow.com/questions/8508433/coldfusion-structdelete-creates-blank-value

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!