Skip to main content
Known Participant
February 27, 2007
Question

Can't get session variables to work

  • February 27, 2007
  • 1 reply
  • 275 views
New to using session variables so hoping someone can point out something obvious that I'm not seeing. Thanks in advance...

Have one file called testinc.cfm:
<cfif IsDefined('session.GLOBALDEF') EQ false>
<cfoutput>Global not defined</cfoutput>
<cfset session.GLOBALDEF = 1>
<cfelse>
<cfoutput>OK</cfoutput>
</cfif>

I have 2 other files, test1.cfm and test2.cfm. Test1 includes testinc.cfm and also has a link to test2.cfm.

Test2.cfm checks to see if the session variable GLOBALDEF is defined (it should be since test1.cfm included testinc.cfm): <cfif IsDefined('session.GLOBALDEF') EQ false>

My problem is that: when I run test1.cfm - it's fine. When I click on the link to test2.cfm, test2.cfm says that GLOBALDEF is not defined. I don't understand. Shouldn't the 'isdef' return true now that the session variable has been created and intialized?

Thanks
    This topic has been closed for replies.

    1 reply

    Inspiring
    February 27, 2007
    You have a <cfapplication ... sessionManagement="true"> tag or a
    Application.cfc this.sessionManagement=true somewhere?

    You have it set up so that all these pages include the same application
    name="myName" property. Different applications with different names
    have different session scopes.

    You have cookies enabled in your browser? CF uses the CFID and CFToken
    cookies to associate a user to a give session. If no cookies, every
    page request generates new ids and tokens, thus new session scopes.