House of Fusion
Search over 2,500 ColdFusion resources here
  
Home of the ColdFusion Community

Mailing Lists
Home /  Groups /  ColdFusion Talk (CF-Talk)

Variables

  << Previous Post |  RSS |  Sort Oldest First |  Sort Latest First |  Subscribe to this Group Next >> 
Top  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
N kips
05/16/2012 09:27 AM

Greetings, just need some help to understand how CF works in regards to variables. Can CF might mix-up the variables, unless the variables are in the session? Is this sufficient? <cfset var = GetAuthUser()> or should I say <cfset session.var = GetAuthUser()> It is just a variable that is used to hold data which will be processed, but the data is different from user to user. Do not want to process one user's data in place of another. Appreciate it.

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Scott Stewart
05/16/2012 09:36 AM

If it's a local variable in a function, you'll scope it as local.varname If it's a local variable in a CFM page, you'll scope it as variables.varname if it's in the request scope, then it's request.varname if it's in the session, then it's session.varname application, application.varname form, form.varname ad nauseum.. On 5/16/2012 9:26 AM, N kips wrote: ----- Excess quoted text cut - see Original Post for more -----

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Robert Harrison
05/16/2012 10:20 AM

If the var is used only within a single program a regular local var is fine.  If the var needs to persist and be recalled from another program later (i.e., a program where the var is not passed as a URL or form value), then use the session.var.   Robert Harrison Director of Interactive Services Austin & Williams Advertising I Branding I Digital I Direct   125 Kennedy Drive,  Suite 100   I  Hauppauge, NY 11788 T 631.231.6600 X 119   F 631.434.7022   http://www.austin-williams.com Blog:      http://www.austin-williams.com/blog Twitter:  http://www.twitter.com/austi

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Cameron Childress
05/16/2012 10:30 AM

The larger question here is developing an understanding of the scopes available in ColdFusion and why you would or wouldn't use them. This is a very fundamental thing that's quite important to understand in order to develop quality ColdFusion applications. Before continuing I'd recommend reading the following: Adobe ColdFusion 9 * Scope types http://adobe.ly/KfuPoP Adobe ColdFusion 9 * Using scopes http://adobe.ly/KfuYsi Adobe ColdFusion 9 * CFC variables and scope http://adobe.ly/Kfv5E5 Hope that helps... -Cameron ----- Excess quoted text cut - see Original Post for more ----- -- Cameron Childress -- p:   678.637.5072 im: cameroncf facebook <http://www.facebook.com/cameroncf>; | twitter<http://twitter.com/cameronc>; | google+ <https://profiles.google.com/u/0/117829379451708140985>;

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Carl Von Stetten
05/16/2012 11:03 AM

Also, be careful using "var" as a variable name.  It is a reserved keyword in ColdFusion.  As Scott mentioned, you can make a variable local to a function by calling it local.varname.  You can also make it local to a function by using the "var" keyword when you create the variable: <cfset var foo = "bar"> HTH, Carl


<< Previous Thread Today's Threads Next Thread >>

Search cf-talk

May 25, 2013

<<   <   Today   >   >>
Su Mo Tu We Th Fr Sa
       1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31   

Designer, Developer and mobile workflow conference