Login Authentication and Static Variables - little confusion

Post Reply
Neofriend
Captain
Captain
Posts: 103
Joined: Wed Dec 23, 2009 3:37 pm
Location: Pakistan

Login Authentication and Static Variables - little confusion

Post by Neofriend » Tue Jun 01, 2010 6:19 pm

Am doing login authentication using ASP.NET C#. Am using dual technologies for logging in, cookies and sessions, both for different situations.

But keeping focus at the question, suppose I've made a class having a static string variable to be accessed from any page. That sounds simple and easy, good.

Now, suppose the site is live. And userA accesses the page first, the static variable will be set according to the calculations as performed and will contain some value.

The real question is, what will happen when userB will come. Will the same system will work for him from very start or will he get the static value set as did by userA.

I'd like it not to set and ...... I've been messing since morning to see the perfect solutions. There are alternates but I thought to ask this and if static variable will be working and loading as new empty variable for every new visitor. Then it'd be great to manage things easily.

Please let me know, thank you.
Neofriend
Captain
Captain
Posts: 103
Joined: Wed Dec 23, 2009 3:37 pm
Location: Pakistan

Re: Login Authentication and Static Variables - little confusion

Post by Neofriend » Wed Jun 02, 2010 12:37 am

Would love to get your expert opinion, Neo.
User avatar
Neo
Site Admin
Site Admin
Posts: 2642
Joined: Wed Jul 15, 2009 2:07 am
Location: Colombo

Re: Login Authentication and Static Variables - little confusion

Post by Neo » Thu Jun 03, 2010 12:24 am

The best way is to use private variables for each user. For example, you can create an object per each user and pass this around for the same user. So the variables are not mixed up with each user. Having static variables, will pass the same value among all users if you intend that. (Sorry for getting more time to answer, I was completely packed up with work and still ROBOT.LK is in a primitive stage with not having much supporters to share their ideas :( ). Lets hope future will be much better for ROBOT.LK.
Neofriend
Captain
Captain
Posts: 103
Joined: Wed Dec 23, 2009 3:37 pm
Location: Pakistan

Re: Login Authentication and Static Variables - little confusion

Post by Neofriend » Tue Jun 08, 2010 10:55 am

Oh oh oh... I've implemented all logic (for that part) using static variables. I knew something is wrong in here. I've implemented them in a detailed way, so I'd just go on with this. And once completed, I will lastly check what happens and how it behaves.

I understand you. Just wish if the reply could have come a bit earlier... besides, am not sure how to implement private variables, i mean in my situation. Will talk more on this later. Thank you.
Post Reply

Return to “ASP & ASP.Net”