HI i have developed a asp.net project with a User Logins.for that i previously used Static variable for store userName of the user and i got a terrible errorbecause static variable is only showed latest Login person userID.
E:X if jhon first Login to the system it shows John in the user ID and then if watson logged after the jhon., then Jhons Login automatically change as watson. i thought server creates separate instances for different users. i i was wrong on that occasion.Then i used session variable for store the userName of the Particular users who login to the system. Then i feel it is ok. but i just want to ensure if i use session variables for store userName , is it create separate instances(sessions) for each and every users with out duplicating same userName Like Static variables did? this could be a very fool question but guys i'm new to that session thing and i want to ensure it before Let the users to preform Live run.
E:x Code
protected void btnSignIn_Click(object sender, ImageClickEventArgs e)
{
if (Page.IsValid)
{
UserValidation UserV = new UserValidation();
int a = UserV.check_Login(UNtxt.Text, PWtxt.Text, List_company_cmbo.Text);
if (a == 1)
{
//Response.Write("<SCRIPT LANGUAGE='JavaScript'>alert('Login is ok')</SCRIPT>");
//Response.Write("<a href='WebForm1.aspx'></a> ");
// WebForm1 wb = new WebForm1();
Session["caption"] = UserV.getFname(UNtxt.Text.Trim());
Session["logged"] = "logged";
Response.Redirect("Home.aspx");
}
Then i called the session variable from Master Page as follows.
protected void Page_Load(object sender, EventArgs e)
{
try
{
if (Session["caption"] == null)
{
}
else
{
U_Name.Text = Session["caption"].ToString();
}
}
catch (Exception ex)
{
ErrorLog el = new ErrorLog();
el.ErrorRegistry(ex, "AntronERPMaster.Master.cs", "cannot perse Login person name to page", "NA", "NA");
}
}
Thanks in Advance!!!