ColdFusion calling session function -


i have user object have in session variable , able update needed. how call function in existing user object manipulate existing variable. found way call function, it's not calling existing object, instead suspect it's instantiating new object before calling function.

in application.cfc:

<cffunction name = "onsessionstart" output="no">     <cfobject name="session._user" component="user"/>     <cfscript>     ...     session._user.init();     </cfscript> </cffunction> 

in user.cfc:

<cffunction name = "init">     <cfscript>         variables.attributes.variable1 = 0;     </cfscript> </cffunction>  <cffunction name="changevariable" access="public">     <cfargument name = "somename">     variables.attributes.variable1 = arguments.somename; </cffunction> 

later on in login.cfm, call session._user.changevariable(2)

if isn't possible, i'll end writing , database keep track of user properties instead of using session variable.

in onsessionstart create object , set session. if using cf10+ can use new() in cf9 , lower need use createobject().

<cffunction name="onsessionstart">   <!--- in cf10+ new calls init() automatically --->   <cfset session._user = new user()>    <!--- cf9 or lower --->   <cfset session._user = createobject('user').init()> </cffunction> 

in login.cfm update session variable

<cfset session._user.changevariable(2)> 

Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -