Defining Session Variables

Discussion in 'Programming' started by Sushi_Master, Oct 30, 2008.

  1. #1
    I have a page which creates a session then sets a variable called 'Session.DotCfmError' as the cgi.path_info then uses a cflocation to redirect to sitemissingpage.htm

    
    <cfapplication name="GetLeadApp" 
    sessionmanagement="Yes"
    sessiontimeout=#CreateTimeSpan(0,0,45,0)#>
    <cflock timeout=20 scope="Session" type="Exclusive">
    <cfset Session.DotCfmError = #CGI.PATH_INFO#>
    </cflock>
    
    <cflocation url="/sitemissingpage.htm">
    Code (markup):
    The template for sitemissingpage.htm carries on the session and uses the 'Session.DotCfmError' variable and works fine, but coldfusion is sending me auto generated error e-mails saying that the variable 'DotCfmError' is not defined.

    I'm not sure how I can fix this without loosing the value stored in the variable?
     
    Sushi_Master, Oct 30, 2008 IP
  2. robhustle

    robhustle Peon

    Messages:
    98
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Sounds like a scope issue. Is the sitemissingpage.htm in a different application scope?

    If not, you might be able to solve it by including the cftoken in the URL.

    Another idea is to write the info in a cookie, then access the cookie instead of a session variable.

    Another idea is to cfinclude the sitemissingpage.htm instead of using cflocation to get to it. If you use cfinclude, all of the current request information is preserved, and you'd have access to the variable you set.

    Not sure exactly what is going on, but maybe one of these ideas will work for you.

    Tell us if you figure it out ;)
     
    robhustle, Oct 30, 2008 IP
  3. Sushi_Master

    Sushi_Master Peon

    Messages:
    55
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #3
    All sorted now.

    I simply set the session variable in the application.cfm and it has stopped throwing the errors.

    This must be something to do with my coldfusion settings as the variable was storing the correct value although the error messages said it was undefined.

    Maybe my method was just bad practice... I'm still learning.
     
    Sushi_Master, Nov 10, 2008 IP