Session variables are getting overritten by different users in different locations

Hi, the session variables I'm using when the application starts, are getting overridden when a second user logs in

On my login page I'am initialising  a structure that contains some user data and I'm assigning that structure to a session variable.

myData md = new myData()
md.id = xx;
md.username = xxx;
Session["myData"] = md

Open in new window


Now, when second user logs in, this data gets overriden by the nbew user and the original user (logged in a different part of the country)  can see the second user data!

Any ideas how to stop this or why it's happening??
Adrian CrossAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Obadiah ChristopherCommented:
This seems highly unlikely. Are you using static when reading the Session variable?
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Adrian CrossAuthor Commented:
It's a structure inside a class in another file

public class MyClass

public struct myData
{
     public string ID;
     public string username;
}

Open in new window


Then from login page aspx Im accessing it like

myData md = new myData();
md.id = 5;
Session["myData"] = md;

It's happening. Im just baffled
0
Obadiah ChristopherCommented:
Have you tried changing the structure to a class
0
JavaScript Best Practices

Save hours in development time and avoid common mistakes by learning the best practices to use for JavaScript.

Adrian CrossAuthor Commented:
Could you please give  me an example?
0
Obadiah ChristopherCommented:
I meant to say that instead of this

public struct myData
{
     public string ID;
     public string username;
}

Use this

public class myData
{
     public string ID;
     public string username;
}
0
Adrian CrossAuthor Commented:
You were right! I have declared a variable as static in another page which I didn't see!
Thanks so much!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP.NET

From novice to tech pro — start learning today.