Click here to Skip to main content
15,884,628 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
Hi,

I have created a web application with 5 forms using asp.net & vb.net.

The system got more than 250 web clients.

My problem is when the second user logs in to the web system, the second user overrides first user's details.

I want to get the User_ID, username, user ID and the selected branch name from the Login page and want to display those information on text boxes in other 5 pages.
So in other pages I want to use user id to extract information from mySQL tables.

This is my code.
Login.aspx.vb (First Form)
VB
Protected Sub bttnLogin_Click(sender As Object, e As ImageClickEventArgs) Handles bttnLogin.Click
     
        Session("UserName") = Server.HtmlEncode(txtUserName.Text)
        Response.Redirect("~/default.aspx";, True)


    End Sub


2nd form
VB
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
       
       lblDetails.Text = Session("UserName")
   End Sub

But at the moment when two or more users logs to the system it's showing the correct usernames on "lblDetails.Text" but when u refresh the page it will show last logged in user's details.





Please help me.



Thanks
Posted
Updated 20-Jan-15 4:45am
v2
Comments
Sergey Alexandrovich Kryukov 20-Jan-15 11:51am    
I an not sure your are properly testing this pages. To see them from the standpoint of two different users, you should use two different sessions. To observe it, you need to test on two different machines, or, quite simple, two different browsers (not instances of the same browser).
—SA

1 solution

it would almost be simpler to pass query string parameters to the next page with the users details. if the user were to refresh the page you are able to retrieve the string parameters to display the user info again and retrieve any info from your database using the parameter.

I would also agree with sergey by using multiple sessions if you went the rout of sessions only.
 
Share this answer
 
v3

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