这个代码在Application.cfm中(我知道它应该可能是.cfc,但这是一些可以追溯到MX的旧代码)用于在CF8和CF9上正常工作的cookie - 但我使用CF10开发人员版将其移至本地目录,直到我将该块注释掉后才能使用。达到索引时出现错误。Session Cookies和Application.cfm
The system has attempted to use an undefined value, which usually indicates a programming error, either in your code or some system code.
Null Pointers are another name for undefined values.
The error occurred in C:/ColdFusion10/cfusion/wwwroot/TFT/Application.cfm: line 3
1 : <!--- APPLICATION settings --->
2 : <cfif IsDefined("cfid")>
3 : <cfcookie name="cfid" value="#cfid#" expires="NOW">
4 : <cfcookie name="cftoken" value="#cftoken#" expires="NOW">
5 : </cfif>
这是当前代码Application.cfm:
<!--- APPLICATION settings --->
<!--- 5/1/13 removed cookies temporarily
<cfif IsDefined("cfid")>
<cfcookie name="cfid" value="#cfid#" expires="NOW">
<cfcookie name="cftoken" value="#cftoken#" expires="NOW">
</cfif>--->
<!--- Define the application parameters--->
<cfapplication name="TFTAdmin" clientmanagement="Yes"
sessionmanagement="Yes"
setclientcookies="No"
sessiontimeout="#CreateTimeSpan('0','4','0','0')#"
applicationtimeout="#CreateTimeSpan('0','4','0','0')#">
<!--- Create cookies that disappear when the browser closes as to increase security --->
<cflock scope="session" type="readonly" timeout="5">
<cfcookie name="cfid" value="#session.cfid#">
<cfcookie name="cftoken" value="#session.cftoken#">
</cflock>
编辑:有没有在这个文件的详细代码 - 但似乎无关紧要。
谢谢。我必须在应用程序声明之后放置(这是有道理的),否则'session'是未定义的。 – Macness 2013-05-03 13:26:32
@Macness上面的答案是不正确的。 'session'不是ColdFusion [范围评估顺序](http://help.adobe.com/zh_CN/ColdFusion/10.0/Developing/WSc3ff6d0ea77859461172e0811cbec09af4-7fdf.html)的一部分。因此,有条件的和上面提出的条件是不一样的。所以代码可能不会出错,但它并没有完成预期的工作。查看我的回答,了解我的想法。 – nosilleg 2013-05-07 19:40:17
@nosilleg不知道这是如何使我的答案不正确?问题是'isDefined()'不看会话变量,所以范围评估顺序实际上证明了我的观点。 – 2013-05-08 01:24:16