Kill Session when Clicking logout
Hello Everyone,, Help me to kill the session when clicking logout. Heres the code
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
<div class="SubFont">
<%
if (Session["User_Idx"] == null)
{
Response.Redirect("Login.aspx");
}
else
{
%>
<span>Welcome <% Response.Write(Session["Fullname"]); %> | </span>
<asp:LinkButton runat="server" ID="lnkLogOut" Text="Logout"
onclick="lnkLogOut_Click" CssClass="ViewLive"></asp:LinkButton>
<%}%>
</div>