Skip to main content
Known Participant
May 28, 2009
Answered

Session variable values dropped

  • May 28, 2009
  • 2 replies
  • 1711 views

I'm tracking entered info on an ecommerce checkout using session variables.  All goes well until a user edits their shipping information.  Suddenly about half of the variables that hold the billing information lose their values.  They are not deleted; they are just empty.

I have scoured the code and there are no errors that would cause the shipping variable updates to affect the billing ones.  The routines are all encased in cfswitch/cfcase tags AND I've commented EVERY bit of executable code on the page and the problem still occurs.  I also tried changing the billing variable names to no avail also.

I'm out of tricks.  Is there some bug or something that's affecting my app?

TIA for any help any of you can offer.

~ValC

    This topic has been closed for replies.
    Correct answer BKBK

    To test, place this line at a place where you're certain all the billing session variables are defined. The duplicate is a clone, and so is a snapshot frozen in a moment in time.

    <cfset session.sessionVarsBeforeShippingInfoUpdate = duplicate(session)>

    Place the following code at a place after the code that processes the shipping information.

    <cfdump var="#session.sessionVarsBeforeShippingInfoUpdate#">
    <br>
    <cfdump var="#session#">

    Compare the values in the two dumps.

    2 replies

    BKBK
    Community Expert
    Community Expert
    May 29, 2009

    Even without seeing the code, one can guess what is happening.The process that sets the shipping information, resets the billing information, perhaps to default values which happen to be empty strings.

    ValCscAuthor
    Known Participant
    May 29, 2009

    You have my attention.  Tell me how/why this would happen.  Convince me.

    There is no mention of the billing set of session vars in the block of code that updates the shipping ones.  Anyhow, when I comment out the entire block the problem still occurs.

    Where could this reset be generated from?

    Thanks for your interest and your help!

    ~ValC

    BKBK
    Community Expert
    BKBKCommunity ExpertCorrect answer
    Community Expert
    May 29, 2009

    To test, place this line at a place where you're certain all the billing session variables are defined. The duplicate is a clone, and so is a snapshot frozen in a moment in time.

    <cfset session.sessionVarsBeforeShippingInfoUpdate = duplicate(session)>

    Place the following code at a place after the code that processes the shipping information.

    <cfdump var="#session.sessionVarsBeforeShippingInfoUpdate#">
    <br>
    <cfdump var="#session#">

    Compare the values in the two dumps.

    Inspiring
    May 28, 2009

    Just curious. Are you using cflocation? If so, there *can* be an issue with losing session vars when using cflocation:

    http://kb2.adobe.com/cps/181/tn_18171.html

    Short of that, can you post some code for us to look at?

    ilssac
    Inspiring
    May 28, 2009

    There is a non-intuitive relationship between the application name set with <cfapplication name="something"...> OR this.applicaitonName = "something".  Any code running on the application must be running in such a way that these are set for every request.  This is usually accomplished by setting this in an Applicaiton.cfm or Application.cfc files.

    When one starts using cfc components, one of the first things many often do is to move the component to some central directory often outside of the web root.  These CFC will not belong to an appliction since they are not running under a directory with one of the above lines.

    This enforces the OOD concept of encapulsation where objects should not rely on data the exists outside of themselves, but rather have all data passed into and stored within them.  Otherwise one needs to understand the relation with persistant scopes and the application name.

    CFID and CFTOKEN or JSESSIONID cookies are also required, but problems with these would usually not just affect a specific portion of the site.

    ValCscAuthor
    Known Participant
    May 28, 2009

    No CFCs here.  The two pages that work together to drop these values are in the same directory, hence, are using the same application name.  Thanks for the thoughts.