Click here to Skip to main content
15,903,362 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Dear Friends,

I am using VS 2008,C#,asp.net,dev express 11
I have a web application.which has a session which contain the logined user's name.
Which is stored when login to the application in login page.

When users are logined concurrently, the label ( shows the username) is getting swapped.
The label is assigned the session value of logined user name.

How to avoid session overlap?
That means The label should show the name of the logined user when logined with different user names concurrently

Thanks in advance
george
Posted
Updated 24-Jun-14 1:58am
v3

Sessions shouldn't overlap as long as they are being tracked appropriately. If this is occurring, there is one of 2 likelihoods:
1. The name is not being stored to the session, but is being stored as a static variable (or in the application state, or cached etc). Moving the name to the HttpContext.Current.Session["userName"] variable should resolve the issue.

2. It's possible that session handling has been modified in the application to a system that is collision-prone. Check the global.asax and make sure that session logic hasn't been modified.
 
Share this answer
 
Comments
george@84 26-Jun-14 8:32am    
Dear Friends,

I assigned values to session when login to a page like the following.


Session["PSFusrCode"] = DSUSERLEVEl.Tables[0].Rows[0]["usrCode"].ToString();



Session.Add("Module", Convert.ToString(Session["Module"]));


Session["PSFUserType"] = DSUSERLEVEl.Tables[0].Rows[0]["ulName"].ToString();
Session["PSFUName"] = DSUSERLEVEl.Tables[0].Rows[0]["usrName"].ToString();

Session["PSFOutlet"] = DSUSERLEVEl.Tables[0].Rows[0]["usrOutlet"].ToString();
Nathan Minier 26-Jun-14 8:53am    
You data access schema is a bit odd. Can you show your data source code without the connection string?

Also:
Session.Add("Module", Convert.ToString(Session["Module"]));
Why?
george@84 1-Jul-14 7:22am    
DataSet DS = new DataSet();

DataSet DSUSERLEVEl = new DataSet();
DataSet DSUSERLEVElOUTLET = new DataSet();

DSUSERLEVEl = objLogin.getPSFLogin(txtUserName.Text.Trim(), txtPassword.Text.Trim());


if (DSUSERLEVEl.Tables.Count > 0)
{


Session["PSFusrCode"] = DSUSERLEVEl.Tables[0].Rows[0]["usrCode"].ToString();



Session.Add("Module", Convert.ToString(Session["Module"]));


Session["PSFUserType"] = DSUSERLEVEl.Tables[0].Rows[0]["ulName"].ToString();
Session["PSFUName"] = DSUSERLEVEl.Tables[0].Rows[0]["usrName"].ToString();

Session["PSFOutlet"] = DSUSERLEVEl.Tables[0].Rows[0]["usrOutlet"].ToString();



Response.Redirect("PSFDashBoard.aspx");
}
public DataSet getPSFLogin(string username, string password)
{
return objUserlevel.getPSFLogin(username, password);
}
public DataSet getPSFLogin(string usr, string pwd)
{
List<sqlparameter> param = new List<sqlparameter>();

param.Add(new SqlParameter("@USERNAME", usr));
param.Add(new SqlParameter("@PASSWORD", pwd));
return DBFUNCTIONS.FILL_DATASET_FROM_SP("USP_INS_GET_PSF_LOGIN", param);
}
First check your code in your system bcose of alyas session are unique in every login so there is not any case to swap the values,
The Rule for session is:

Session is conman for hole application but different for every users.
 
Share this answer
 
Comments
george@84 1-Jul-14 7:25am    
the following is the code
DataSet DS = new DataSet();

DataSet DSUSERLEVEl = new DataSet();
DataSet DSUSERLEVElOUTLET = new DataSet();

DSUSERLEVEl = objLogin.getPSFLogin(txtUserName.Text.Trim(), txtPassword.Text.Trim());


if (DSUSERLEVEl.Tables.Count > 0)
{


Session["PSFusrCode"] = DSUSERLEVEl.Tables[0].Rows[0]["usrCode"].ToString();



Session.Add("Module", Convert.ToString(Session["Module"]));


Session["PSFUserType"] = DSUSERLEVEl.Tables[0].Rows[0]["ulName"].ToString();
Session["PSFUName"] = DSUSERLEVEl.Tables[0].Rows[0]["usrName"].ToString();

Session["PSFOutlet"] = DSUSERLEVEl.Tables[0].Rows[0]["usrOutlet"].ToString();



Response.Redirect("PSFDashBoard.aspx");
}
public DataSet getPSFLogin(string username, string password)
{
return objUserlevel.getPSFLogin(username, password);
}
public DataSet getPSFLogin(string usr, string pwd)
{
List param = new List();

param.Add(new SqlParameter("@USERNAME", usr));
param.Add(new SqlParameter("@PASSWORD", pwd));
return DBFUNCTIONS.FILL_DATASET_FROM_SP("USP_INS_GET_PSF_LOGIN", param);
}

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