5 Replies Latest reply on May 1, 2008 5:14 AM by BKBK

    session vars, CFCs and CFHTTP

    wezcornell2008
      Hi guys

      I'm using session vars to maintain whether or not a user is logged in on our site. The only problem is is that the session vars seem to be lost after I call a CFC that then does a CFHTTP post.

      Does anyone know how I maintain the session vars?

      I'm using CF MX 7

      All the best

      Wez
        • 1. Re: session vars, CFCs and CFHTTP
          Level 7
          wezcornell2008 wrote:
          > Hi guys
          >
          > I'm using session vars to maintain whether or not a user is logged in on our
          > site. The only problem is is that the session vars seem to be lost after I call
          > a CFC that then does a CFHTTP post.
          >
          > Does anyone know how I maintain the session vars?
          >
          > All the best
          >
          > Wez
          >


          Why do you say they are lost? Are you sure you did not just misplace them?

          In other words nothing about CFC's or CFHTTP would intrinsically destroy
          session variables in memory. But they could easily not have access to
          the scope as you desire if you do not understand how templates and cfml
          code are associated with a given session scope when it is running in memory.

          • 2. Re: session vars, CFCs and CFHTTP
            wezcornell2008 Level 1
            Thanks for the reply.

            Thank you for clarifying that the session vars are not 'lost'. I was hoping that would be the case.

            Please could you expand on how I would regain access to them through the correct scope.

            Many thanks in advance.

            Wez
            • 3. Re: session vars, CFCs and CFHTTP
              Dan Bracuk Level 5
              My method is to not use session variables inside cfc's. Anything the functions need are passed as arguments.
              • 4. Re: session vars, CFCs and CFHTTP
                Level 7
                > Please could you expand on how I would regain access to them through the
                > correct scope.

                Posting the relevant bits of your code and telling us exactly what's going
                on, and how you've tried to troubleshoot it would be a good start.

                --
                Adam
                • 5. Re: session vars, CFCs and CFHTTP
                  BKBK Adobe Community Professional & MVP
                  Wez wrote:
                  Does anyone know how I maintain the session vars?

                  Yes. Do the following:

                  1) Navigate to Server Settings => Memory Variables in the Coldfusion Administrator. Enable the use of application variables as well as session variables.

                  2) Your Application.cfc file should at least contain a setup like this
                  <cfscript>
                  this.name = "yourAppName";
                  this.applicationTimeout = "#createTimeSpan(1,0,0,0)#";
                  this.sessionManagement = "yes";
                  this.sessionTimeout = "#createTimeSpan(0,0,20,0)#";
                  </cfscript>