Skip to main content
January 15, 2012
Question

how to make a variable global to use in all of my cfm page?

  • January 15, 2012
  • 2 replies
  • 1318 views

I have a problem with the variables.

i need to use a variable  " loginrecord" in all of my cfm pages, its created in my login.cfm and the value of this needed in other page and maybe i need to change it .

in ASP simply we can use SESSION to make a variable global , is there any way in coldfusion ?

also in ASP we have a command SESSION.SESSIONID ,  so return the unique number from browser and we can se it as a security check for each one of people login to our site and each one is seperate random and unique number , is there any similar in coldfusion ?

Thanks

Alireza

This topic has been closed for replies.

2 replies

BKBK
Community Expert
Community Expert
January 23, 2012

Ali Parsa wrote:

I have a problem with the variables.

i need to use a variable  " loginrecord" in all of my cfm pages, its created in my login.cfm and the value of this needed in other page and maybe i need to change it .

in ASP simply we can use SESSION to make a variable global , is there any way in coldfusion ?

Session.loginrecord will make the variable available to all the CFM pages  visited during the session.

also in ASP we have a command SESSION.SESSIONID ,  so return the unique number from browser and we can se it as a security check for each one of people login to our site and each one is seperate random and unique number , is there any similar in coldfusion ?

ColdFusion has session.sessionID, too.

Inspiring
January 15, 2012

You can also use session variables in ColdFusion. 

January 15, 2012

i use it but not working

i set it in application.cfm

<cfset request.loginsession=0>

but when i change the value in other page, ( like index.cfm ) i can not retrive it in other page ( like clients.cfm )

Community Expert
January 16, 2012

You just set a request variable, not a session variable.

<cfset session.foo = "I am a session variable, and will be available on every page viewed by this user, or any program called by these pages, until the session expires">

<cfset request.foo = "I am a request variable, and will be available in all programs called by this current page request.">

<cfset application.foo = "I am an application variable, and will be available on every page within this application viewed by any user, or any program called by these pages, until the application expires">

<cfset server.foo = "I am a server variable, and will be available on every page viewed by any user or any program called by these pages, anywhere on the server">

I would strongly recommend you spend some time reading the documentation, which is very well written and all online.

Dave Watts, CTO, Fig Leaf Software

Dave Watts, Eidolon LLC