Click here to Skip to main content
15,891,981 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
My variables is retaining its value even if other computers accessing my website. for example, i logged in the pc 1 using Username - User1. when i access the site on pc 2, the User1 is already logged in. Hope some one could help me on this.

i have a variable

public Username as string

then the code is
C#
Username = txtUsername.text 

Im going to log in to PC 1 using username "test_user1"

when i access the website on another pc or computer, the username "test_user1" is still on the variable Username.

The question is why it inherit or retain the value of the variable "Username" on other computers?

i used this codes below
C#
Protected Sub btnLogin2_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles btnLogin2.Click

Username = txtUsername.text
FormsAuthentication.RedirectFromLoginPage(Username, False)
Response.Redirect("~/frmMenu.aspx", False)

End Sub


Its not about the authentication, its about the variable i declared on the module and why it has same value accross other computers accessing my website.
Posted
Updated 28-Apr-14 22:58pm
v3
Comments
DamithSL 29-Apr-14 3:09am    
can you update the question with login code ?
miyakee 29-Apr-14 3:27am    
i have a variable

public Username as string

then the code is

Username = txtUsername.text


Im going to log in to PC 1 using username "test_user1"

when i access the website on another pc or computer, the username "test_user1" is still on the variable Username.

The question is why it inherit or retain the value of the variable "Username" on other computers?

i used this codes below
Protected Sub btnLogin2_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles btnLogin2.Click

Username = txtUsername.text
FormsAuthentication.RedirectFromLoginPage(Username, False)
Response.Redirect("~/frmMenu.aspx", False)

End Sub
OriginalGriff 29-Apr-14 3:18am    
This is not a good question - we cannot work out from that little what you are trying to do.
Remember that we can't see your screen, access your HDD, or read your mind.
Use the "Improve question" widget to edit your question and provide better information.
miyakee 29-Apr-14 4:02am    
sorry sir..
Dinesh.V.Kumar 29-Apr-14 3:27am    
Try keeping the user information in session rather than application variables.

Might be you have used Static variable in your project. due to this the problem may caused , check it again.
 
Share this answer
 
Comments
miyakee 29-Apr-14 3:38am    
i dont know if it is static. i just declared it on a module like this
Public EmpName As String
[no name] 29-Apr-14 3:41am    
put your full login page code
miyakee 29-Apr-14 3:44am    
Imports System.Data.SqlClient<br>
Module modDeclaration <br>
Public AdminUser As Int16<br>
Public EmpName As String<br>
End Module<br>
 <br>
on the webform<br>
 <br>
Protected Sub btnLogin2_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles btnLogin2.Click<br>
 <br>
EmpName = txtUsername.text<br>
FormsAuthentication.RedirectFromLoginPage(EmpName , False)<br>
Response.Redirect("~/frmMenu.aspx", False)<br>
 <br>
End Sub<br>
 <br>
[no name] 29-Apr-14 3:49am    
http://forums.asp.net/t/1200058.aspx?+FormsAuthentication+RedirectFromLoginPage+Problem
this might help you
miyakee 29-Apr-14 4:31am    
Its not about the authentication. Its about the variable and its value why is it staying even if i use other computers. Multiple computers accessing my website, and the value of the variables are i think the same.
check if you has declared variable as public static this could be a reason of such case.
And if you want to access this name to another form then use query string or if you want to access it through-out the session store it in session.
 
Share this answer
 
v2
Comments
miyakee 29-Apr-14 4:52am    
Yes i declare the variable in a module as Public. Is there an alternative way other than using session in it?

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