Skip navigation
Currently Being Moderated

Correct Scope for sessions

Apr 17, 2012 11:35 AM

I have to pass a value using a session, I want to create a session based on the UID of the item in question, and there will be several of them, so I might have UID:23, UID:40, UID: 200 for example. Then on the following page I can relate that value back using UID.


The question is, what is the correct format for this? Could anybody post an example of


a) How I set the session name, let's say that the UID is stored in a query variable #GETCAMP.CAMP_UID#


b) How would I then read it back (The value of getcamp.camp_uid) is also passed through


I know this is not right but I think I might be close with -->



<CFSET session.[getcamp.camp_uid] = "#getcamp.camp_uid#">








  • Currently Being Moderated
    Apr 17, 2012 4:02 PM   in reply to ACS LLC

    You could put an empty structure into your session scope and add keys to it as required.  Be careful about what you put into the session scope though.  With all browser tabs and new browser windows sharing the same session, it's possible for values to be mistakenly overwritten.

    Mark as:
  • Currently Being Moderated
    Apr 18, 2012 12:46 AM   in reply to ACS LLC

    Could you possibly give me a small example of what you were describing?



    There's a whole section in the docs about how to use variables in CF.  You should really make sure you know this stuff thoroughly if you're using CF (as it's about as fundamental as it gets when using a programming language):



    Specifically: 461172e0811cbec09af4-7fee.html


    struct[dynamicKeyName] = value


    Where "struct" is the struct one is using (and a scope - for all intents and purposes - is a struct), "dynamicKeyName" is a string or a variable containing a string which is the name fo the key, and "value" is... err... the value.


    But don't take my word for it: read the docs and get up to speed with all this stuff.




    Mark as:
  • Currently Being Moderated
    Apr 23, 2012 1:27 AM   in reply to ACS LLC

    Please kindly mark thread as answered. It will help others.

    Mark as:
  • Currently Being Moderated
    Apr 23, 2012 8:10 AM   in reply to ACS LLC


    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