The Session var getting set in my web service does not seem to stick

In my web service I am setting a Session var Session["USERINFO"]

But when I go back into the web form later....and it loads the data from Session["USERINFO"] -- it is the OLD data not the new data.

Why might that be?

        [WebMethod(EnableSession = true)]
        public string UpdateExistingUser(string tbPassword, string tbPasswordConfirm, string tbFirstName, string tbLastName, string tbAddress1, string tbAddress2, string tbCity, string BillingState, string tbZip, string tbShipFirstName, string tbShipAddress1, string tbShipAddress2, string tbShipCity, string ShippingState, string ShippingCountry, string tbShipZip, string tbEmail, string tbDayPhone, string tbNightPhone, string BillingCountry, string tbShipInstructions, string CheckBoxCopyBillToShip, string cbEmailOptIn)
        {
            string status = "failed";

            List<object> parmspassedback = new List<object>();

            DataTable dt = new DataTable();
            DataTable dtafter = new DataTable();

            dt = null;

            dt = Session["USERINFO"] as DataTable;
                        
            parmspassedback = GlobalMethods.UpdateExistingUser(tbPassword, tbPasswordConfirm, tbFirstName, tbLastName, tbLastName, tbAddress2, tbCity, BillingState, tbZip, tbShipFirstName, tbShipAddress1, tbShipAddress2, tbShipCity, ShippingState, ShippingCountry, tbShipZip, tbEmail, tbDayPhone, tbNightPhone, BillingCountry, tbShipInstructions, CheckBoxCopyBillToShip, cbEmailOptIn, dt, "");

            dtafter = ((DataTable)parmspassedback[1]);

            Session["USERINFO"] = null;

            if (dtafter != null)
            {
                Session["USERINFO"] = dtafter;
            }

            return parmspassedback[0] as string;
        }//end of web method

Open in new window

LVL 5
Tom KnowltonWeb developerAsked:
Who is Participating?
 
ddayx10Commented:
Its been awhile since I tested this all the way through but I believe in your web service if you interact with your session in this way it will work:

Context.Session["USERINFO"]
0
 
Tom KnowltonWeb developerAuthor Commented:
As it turns-out, I think I was okay.  The symptoms made me think it was the Session variable, but further investigation revealed a problem with saving the changes.

Anywho, thanks for your time!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.