Using SESSION to record number of surveys completed RRS feed

  • Question

  • User1389508859 posted

    Hey there,

    I thought I had this but what I have currently only works if the browser does not close.

    What I am trying to do is keep a continuous track record of how many individuals have successfully completed and submitted a survey. The survey itself was created using the Wizard tool in VS Studio Express, Web (2012). The values are getting successfully stored in a database, however the survey count number does not increment as expected.

    I think I'm on the right track - obviously just missing the part where the value stays whether the browser remains opened or closed.

    Hopefully that makes sense; my code is below.

    // Count survey number
                if (Application["lastSurveyCount"] != null)
                    int curSurveyCount = Convert.ToInt16(Application["lastSurveyCount"]) + 1;
                    Session["surveyCount"] = curSurveyCount.ToString();
                    Application["lastSurveyCount"] = 1;
                    Session["surveyCount"] = Application["lastSurveyCount"];

    Tips and/or advice?

    ** Edit: Upon doing more research, I see PROFILES may be the ticket, however much more complicated. Are there simpler ways?

    Saturday, October 12, 2013 6:04 PM


  • User-1454326058 posted

    Hi mallorz,

    Thanks for your post!

    Based on my test in IE10, the SessionId will be lost when first close the browser and the SessionId will be remained regardless of the browser has been closed or not if get session again for the same request. I think that is the storage mechanism of browser.

    So, I suggest that you could consider use the cookie and set the expiration time or store the data in the database.


    Best Regards

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, October 14, 2013 4:49 AM