For CS
protected void lnkLogOut_Click(object sender, EventArgs e)
{
CLMSDataContext context = new CLMSDataContext();
try
{
Object uid = Session["User_Idx"];
Dim_User usr = context.Dim_Users.Single(u => u.User_Idx == Convert.ToInt32(uid));
Session["User_Idx"] = null;
Session["fullname"] = null;
Session["errorlog"] = null;
Session.Clear();
//usr.Status = null;
context.SubmitChanges();
Response.Redirect("~/Login.aspx");
Server.Transfer("Login.aspx");
}
catch (Exception ex)
{
Response.Write(ex.Message);
}
finally
{
context.Dispose();
}
}
For ASPX
<%
if (Session["User_Idx"] == null)
{
Response.Redirect("Login.aspx");
}
else
{
%>
Welcome <% Response.Write(Session["Fullname"]); %> |
<%}%>

Suthish NairPosted Nov 23, 2012, 7:37 AM
Session["User_Idx"] = null;
Session["fullname"] = null;
Session["errorlog"] = null;
Session.Clear();
Add
Session.RemoveAll();
Session.Clear();
Session.Abandon();
Response.AppendHeader("Cache-Control", "no-store");
Response.Cookies.Add(new HttpCookie("ASP.NET_SessionId", ""));
Response.Cache.SetCacheability(HttpCacheability.NoCache);
Then redirect.. this will prevent Session Hijacking also...
Krishna GaradPosted Nov 23, 2012, 7:18 AM
mary jean ligasPosted Nov 23, 2012, 6:24 AM
Session.Abandon();
Session.RemoveAll();
Session.Clear();
But still when i clicked browsers back button the session never expire..
Krishna GaradPosted Nov 23, 2012, 6:20 AM