Knowledge Walls
Gopal Rao
Mumbai, Maharashtra, India
How to do logout in in programs of
When you are making logout button you have to keep that button in master page so that it will appear in all the pages.While doing logout you have to remove the session variable because when you doing login you have used session variable to store the value of user name for some reason.In this example i done the same thing.In this example, i showed one label with the value of session variable and log out bitton. 
<!-- Add this code in master page .aspx -->
<div class="loginDisplay">
                <asp:Label ID="lblUser" runat="server"></asp:Label>
                <asp:Button ID="Sign_out" runat="server" onclick="Sign_out_Click"
                    Text="Signout" />
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace cdManage
    public partial class SiteMaster : System.Web.UI.MasterPage
        protected void Page_Load(object sender, EventArgs e)
            lblUser.Text = Session["userName"].ToString();//taking value of variable during page load.showing in lable.

        protected void Sign_out_Click(object sender, EventArgs e)
            Session.Remove("userName");//remove the session variable
            Response.Redirect("Home.aspx");//redirect to login page or some other page.
Best Lessons of ""
Top lessons which are viewed more times.
  Copyright © 2014 Knowledge walls, All rights reserved
keep your tutorials and learnings with KnowledgeWalls. Don't lose your learnings hereafter. Save and revise it whenever required.
Click here for more details