session - Why is onSessionStart() not run before onRequestStart()? -
assume following site architecture:
/application.cfc /index.cfm /sub/application.cfc /sub/index.cfm /login/index.cfm
now, here's basic pseudo-code:
/application.cfc:
<cffunction name="onsessionstart" returntype="void" output="false"> <cfscript> session.isloggedin = false; return; </cfscript> </cffunction> <cffunction name="onrequeststart" returntype="boolean" output="false"> <cfargument name="targetpage" type="string" required="true"> <cfscript> if (session.isloggedin) request.cart = {}; </cfscript> <cfreturn true /> </cffunction>
/sub/application.cfc
<cffunction name="onrequeststart" returntype="boolean" output="false"> <cfargument name="targetpage" type="string" required="true"> <cfscript> super.onrequeststart(arguments.targetpage); </cfscript> <cfif not session.isloggedin> <cflocation url="/login/" addtoken="false" /> </cfif> <cfreturn true /> </cffunction>
when request /sub/index.cfm, following exception: element isloggedin undefined in java object of type class [ljava.lang.string;.
on local development machine, have debugging information turned on, can see session initialized, @ least cookie standpoint, but, can see, session variables not initialized:
session variables: cfid=149415 cftoken=b7740eb6d2219f83-619ff01b-78ac-c0a4-1997ec503da43982 sessionid=prudential_2ua1130dbk_2_149415_b7740eb6d2219f83-619ff01b-78ac-c0a4-1997ec503da43982 urltoken=cfid=149415&cftoken=b7740eb6d2219f83-619ff01b-78ac-c0a4-1997ec503da43982
i cannot understand why onrequeststart() being called before onsessionstart(). shouldn't onsessionstart() called first?
Comments
Post a Comment