I tried to rewrite my Application.cfc
and other .cfc
files in my system with cfscript
. There is few things that I'm not sure how they work in cfscript. I'm wondering about defining variables inside of the functions. For example onRequestStart()
function looks like this:
function onRequestStart(required string thePage) returntype="boolean" output="false" {
var request.appCode = "MyApp";
var request.appName = "Single Page Application";
var page = listLast(arguments.thePage,"/");
var onApplicationStart();
if(!listFindNoCase("Home.cfm,Auth.cfc",page)){
if(structKeyExists(SESSION, "loggedin") AND SESSION.loggedin EQ false){
location(url="https://www.myapp.org", addToken="false");
}
}
return true;
}
Do I need to use var
word in situations where I'm defining request/session
variables? If I do what is the best practice, use var word or use local.variablename
? Is local
and variables
same in cfscript
?