Skip navigation
Ali Parsa
Currently Being Moderated

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

Jan 15, 2012 11:33 AM

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

 
Replies
  • Currently Being Moderated
    Jan 15, 2012 12:52 PM   in reply to Ali Parsa

    You can also use session variables in ColdFusion. 

     
    |
    Mark as:
  • Dave Watts
    747 posts
    Mar 11, 2003
    Currently Being Moderated
    Jan 15, 2012 4:48 PM   in reply to Ali Parsa

    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

     
    |
    Mark as:
  • Currently Being Moderated
    Jan 15, 2012 7:27 PM   in reply to Ali Parsa

    In addition to Dave's comments, if you are writing a new app, consider using Application.cfc instead of Application.cfm.  In the long run it will make things simpler.

     
    |
    Mark as:
  • Currently Being Moderated
    Jan 23, 2012 1:12 PM   in reply to Ali Parsa

    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.

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points