3 Replies Latest reply on May 8, 2009 5:10 AM by BKBK

    index.cfm and / have different sessions?

    Hardrocksr

      Hi,

       

      I have an applcation that has an Application.cfm file in the Application.cfm file I have the app set up for cookie session management.

       

       

      <cfapplication

      name="app"

      clientmanagement="yes"

      setclientcookies="yes"

      sessionmanagement="yes"

      sessiontimeout="#CreateTimeSpan(0,2,0,0)#"

      applicationtimeout="#CreateTimeSpan(10,0,0,0)#">

       

      all of the following pages are in the root directory for a site

       

      ex: devsite.company.com/

       

      If i got to page login and set session.accountid, session.accountid is set for all pages EXCEPT the index.cfm page.

       

      If i go to devsite.company.com/ session vars are INCORRECT

      devsite.company.com/index.cfm session vars are INCORRECT

      devsite.company.com/login.cfm session cars correct

      devsite.company.com/xyz.cfm session vars are correct

       

      what the heck could be up with the index.cfm page? why is it using a different session?

       

      thanks for any help or ideas

        • 1. Re: index.cfm and / have different sessions?
          newchickinCF Level 1

          You said:

           

          I have an applcation that has an Application.cfm file in the Application.cfm file I have the app set up for cookie session management.

          Can u tell how you are invoking the one Application.cfm within another.

           

          Try using Application.cfc and set all the session variables in onSessionStart Method and Then see how it goes.

           

          If You need to add another Application.cfc file,

           

          you can do so by using <cfmponent extends="Application.cfc">

           

          that will inevitably have diffrent results as i do not know what exactly other Application.cfm or Application.cfc file will be having.

           

          Cfdump on every single page what goes on.

           

          I suggest you don't include application.cfm within another Application.cfm, then see what and how it goes

          • 2. Re: index.cfm and / have different sessions?
            Dan Bracuk Level 5

            To gather more information on what is happening, refresh your index.cfm page and see if the session variables change.

            • 3. Re: index.cfm and / have different sessions?
              BKBK Adobe Community Professional & MVP

              You have to improve the design. The existence of a login page means that your site requires authentication. This in turn implies that you expect the user to initially land on the login page.

               

              However, there is a contradiction. Since the index.cfm page is in the same directory as Application.cfm, Coldfusion will automatically take the user there, irrespective of whether he is logged in or not. I suspect that Coldfusion simply creates a new session when the user navigates between index.cfm and the login page.

               

              One way to resolve the problem is to put code in Application.cfm to test whether a user is logged in and, if not, to redirect him to the login page. If you're on Coldfusion MX7 or newer, consider using Application.cfc instead. These kinds of problems are easily solved in Application.cfc's  onRequestStart() method.