Alecu
Alecu

Reputation: 2708

ASp .net Session variables persistance and modifications

I am using the standard session in asp .net to store some user variables. My problem is that in the code I change some fields in the variables that I fetch from the session. So my question is, what should I do? How should I handle the variables to be sure that the latest changed version is always stored in the session. Is there some kind of mechanism to do this?

Upvotes: 1

Views: 69

Answers (1)

invernomuto
invernomuto

Reputation: 10221

You should wrap your session value in a property then read and write only that property

public string MyVal{
  get{
   return Session["myVal"];
  }
  set{
   Session["myVal"]= value;
  }

}

Upvotes: 1

Related Questions