Click here to Skip to main content
15,892,298 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
I am developing Web Application in which more than one user can login at the same time and do something with database; their we want to use their unique ID to authenticate them.

So how we can hold their unique ID like UserID in Session, we have done like this:
C#
Session["UserID"]=UserID.ToString();


But there is a issue.
While inserting data into DB with their unique IDs, it is replacing their IDs with one another, while logging in from anywhere in the same application.

Please provide solution for the same.

Thanks in adavnce!
Posted
Updated 16-May-13 22:31pm
v4
Comments
Mohammed Hameed 16-May-13 6:42am    
How it will be replaced, actually it shouldn't be. From where you are getting UserID?
Dev Ashish Jangid 16-May-13 7:09am    
Hi Mohammed Sir,

When i Check User Name and Password, we get UserID of that user from DB after successfully authentication...
Mohammed Hameed 16-May-13 7:19am    
Okay, can you tell me what's the actual type of UserID?
Dev Ashish Jangid 16-May-13 7:32am    
can you ask about its datatype...?
its Bigint in DB..
BobJanova 16-May-13 7:15am    
Using the user name or ID as a key and storing that in the session is fine. It's more likely that your database query is at fault if you are having trouble in that area.

Session already is per user, that is handled by IIS. Each time a user connects they get a unique session and you do not need to code for it.
 
Share this answer
 
In ideal case this issue should not happen.

But anyhow I think there is certainly some other issue is there;

1. May be that's at your DB side: Like UserID column is not unique key and hence duplicate user IDs are being created in your table. Due to which this login problem occurs.
2. OR may be there is some issue within your app code like you might have used static keyword.


So verify these two things thoroughly & let me know....
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900