Skip to main content
July 30, 2009
Question

New session on every refresh??

  • July 30, 2009
  • 2 replies
  • 1698 views

Having trouble with my application, in development it works perfectly. as soon as I upload to the production server every request gets a new session...  i.e. I can refresh the same page and see a new session every time thereby preventing me logging in]

I've checked the server setup pretty carefully but have no clue as to why this is happening.

anyone come across this?

coldfusion MX8 + Centos 5...

help!

-sean

    This topic has been closed for replies.

    2 replies

    July 31, 2009

    Are you running multiple CF instances in a clustered configuration?

    August 1, 2009

    no - but now it get's weirder: the sessions no longer "reset" I get a conbsistent session id per borwser. but no the onSessionStart method runs on every request!???

    I cross posted this in advanced techniques....

    having some difficulty with a remote server running the onSessionStart method on every request. Note: this works perfectly in development.

    I have this in my application cfc - note where I am dumping the session variable to screen for debugging. what I have noticed is that the onSessionStart method runs every time, resetting the users login [user can;t log in] it used to give a new session id every request, now that has stopped, but no closer to a solution:

        <!--- session handling --->
        <cffunction name="onSessionStart" output="true" access="public" >
       
            <cflock scope="session" timeout="5" type="Exclusive">
                <cfscript>
                    Session.starttime = now();
                    session.authenticated = "false";
                    session.authattempts = 0;
                    Session.shoppingCart = ArrayNew(2);
                </cfscript>
            </cflock>   
            Session start<cfdump var="#session#" /><br />   
        </cffunction>
       
        <cffunction name="onSessionEnd" output="false" access="public" >
        Session end<cfdump var="#session#" /><br />
        </cffunction>
          
        <!---  request handling --->
        <cffunction name="onRequestStart" output="true" access="public" >
       
            <cfargument name="requestname" required=true/>
            request start<cfdump var="#session#" /><br />
            <cfparam name="message" default="" />
            <cfparam name="success" default="" />
            <cfparam name="error" default="" />
           
            <cfif session.authenticated is not session.sessionid >
                <cfinclude template="./login.cfm" />
            </cfif>

        </cffunction>
       
        <cffunction name="onRequest" output="yes" >
            <cfargument name="targetPage" type="String" required="true" />       
                the request<cfdump var="#session#" /> <br />
                <cfif session.authenticated is session.sessionid>
               
                <cfscript>
                if (IsDefined("url.delFromCart")){
                    cart_obj = CreateObject("component", "cfc.cart");
                    cart_obj.delFromCart(url.delFromCart);
                }
                </cfscript>
               
                <cfsavecontent variable="myContent">
                    <cfinclude template="..#arguments.targetPage#" />
                </cfsavecontent>
               
                <cfoutput>#myContent#</cfoutput>
                </cfif>
           
        </cffunction>
       
        <cffunction name="onRequestEnd" output="yes" access="public" >
            request end<cfdump var="#session#" /> <br />
        </cffunction>

    Has anyone seen this? must be a server error right?

    HELP!!

    -sean

    BKBK
    Community Expert
    Community Expert
    August 16, 2009

    For a start, delete out the lock. A session lock is unnecessary in onSessionStart.

    Have you enabled sessions in the Administrator? If so, what settings do you apply? How did you define sessiontimeout, setClientCookies, etc. in Application.cfc?

    Does the problem persist after you comment out the following code?

    <cfif session.authenticated is not session.sessionid >
                 <cfinclude template="./login.cfm" />
             </cfif>

    If so, then you can at least rule out the login apparatus. Chances are, your application is simply failing to maintain sessions between requests

    July 31, 2009

    Are you using a cookie to set your session, if so are you allowing your browser to set a cookie for your development server and not your production server?

    July 31, 2009

    nope - the cookie behaviour is correct, still stumped.