• Coding
  • Session variable being overwritten ASP.NET

Hello all,

Im having problems witht the session variable being overwritten by other users.

The application is written in asp.net

Scenario:

1- User A logs in the system, starts working on a certain application which is relative to his session.
2- User B logs in the system from another computer.
3- Somehow User A session variable changes and the application he was working on loads different data from the session of user B.

Now my question is:

1- is it a code problem or server configuration problem.

Thanks,
I would guess an issue in your code.

But my guess is worthless. If you want something valuable, show us ... anything.
We cannot really help you without seeing some code. But generally, stay away from using session variables. Save to the database instead of saving to the session.
I think I found out the issue, apparently if both users are working on the same application, and the session variable is being saved to a public object. then on the page load of the application the object is saved to a static variable. if I remove the static property from the variable I know longer experience the issue. I've read somewhere that static variable shares with all isntances, can anyone confirm

http://forums.asp.net/t/1694354.aspx/1

Thanks for your feedback
arthas wroteI think I found out the issue, apparently if both users are working on the same application, and the session variable is being saved to a public object. then on the page load of the application the object is saved to a static variable. if I remove the static property from the variable I know longer experience the issue. I've read somewhere that static variable shares with all isntances, can anyone confirm

http://forums.asp.net/t/1694354.aspx/1

Thanks for your feedback
yup, static variables are shared for all objects of the class...
Yup, static members are not thread safe.

Read more about concurrency management in .NET in order to understand what's really going on.