Click here to Skip to main content
16,016,580 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
Hi
I have developed a small web based school management system.In that a logout button is placed in the masterpage .in that logout buttons click i have set a session variable and redirect the page to logout.aspx page.In that page in the page load i have cleared the session and redirect to login page .But logout is happening when i doing something in the system without actually logging out.code sample is given below:

C#
  protected void logoutbtn_Click(object sender, EventArgs e)
    {
        Session["logout"] = "true";

        Response.Redirect("logout.aspx");
    }


protected void Page_Load(object sender, EventArgs e)
   {
       if(!IsPostBack)
       {
           if (Session["logout"] != null)
           {

               Session.Clear();
               Response.Redirect("Login.aspx");
           }

       }
   }


waiting for reply
Posted
Updated 28-Jan-13 2:11am
v2

C#
if (Session["logout"] != null)
{
  if (Session["logout"] == "true")
  {
    Session.Clear();
    Response.Redirect("Login.aspx");
  }
}


Edit:
I had the same problem when developing my own app.
If you are interested in how I solved it you can view the article here.[^]
 
Share this answer
 
v2
Comments
meenavinaymenon 8-Feb-13 8:10am    
The problem still persists..please help me.
Marco Bertschi 8-Feb-13 8:12am    
Maybe the solution 2 by sisir pato helps you?
meenavinaymenon 14-Feb-13 1:49am    
I tried the second solution,Still same problem please help me to recover from this.
Marco Bertschi 14-Feb-13 4:26am    
Mh... I faced the same issue when developing my own app (it is using master pages too).
I wrote my solution down to an article because I thought that there are other people suffering from the same problem:
http://www.codeproject.com/Articles/535520/Basic-Login-functionalities-for-ASP-Net-4-0
meenavinaymenon 18-Mar-13 7:58am    
Thanku Marco
HI,

On logout button click clear the session values using any one of the following code:

C#
Session.Clear();

or

            Session.Abandon();


Thanks
 
Share this answer
 

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