Reputation: 3103
I Write into a session user login. I need to get user login on server side page when a session is dropped. I try:
private string currentUserLogin;
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
if (HttpContext.Current.Session["curUserRole"] == null)
{
// try to get a "currentUserLogin" varialbe, but it null!
}
else
{
currentUserLogin = HttpContext.Current.Session["curUserLogin"].ToString();
}
}
}
Upvotes: 0
Views: 181
Reputation: 45096
In the Global.asax there is a SessionEnd event. I use it to write to write to to a log file the userID and logoff date/time.
Upvotes: 0
Reputation: 16144
Store the information from the session into cookie (with desired expiration time) & retrieve the value from cookie when session expires.
Upvotes: 1