Saturday, February 26, 2011

How to create a LOGOUT Page using Sessions

Hi Friends I am already explained in my previous post how to create Login Page in asp net Click Here.
Now i am going to explain you how to create a Logout Page

 First open the Microsoft visual studio 2008

Next, add one Web Form and change the name as Logout.aspx
Next, open the code page that is Logout.aspx.cs
And write the following code in the page load

protected void Page_Load(object sender, EventArgs e)
{
Session.Abandon();
Session.Remove("Username");
FormsAuthentication.SignOut();
// Response.Redirect(Request.UrlReferrer.ToString());
Response.Redirect("Logout.aspx");

}

That’s it. If you have any queries please let me know.i am always ready to share my knowledge with you..
developercode
About the Author
Sayyad is a Software Engineer, Blogger and Founder of Developers Code from India.His articles mainly focus on .Net (Web and Windows based applications), Mobile Technologies (Android,IPhone,BlackBerry) and SEO.

Labels: , , , , , ,

8 Comments:

At September 2, 2011 at 12:50 PM , Anonymous Anonymous said...

Its very simple thanks,

 
At January 31, 2012 at 11:01 AM , Anonymous Anonymous said...

can i hav the link to the page wher u hav explained hw to login using sessions...thaks

 
At January 31, 2012 at 11:15 AM , Blogger Developers Code said...

Sure ..Click here to know the procedure

http://www.developerscode.com/2011/02/how-to-create-login-page-in-aspnet-with.html
http://www.developerscode.com/2011/02/how-to-transfer-values-from-one-page-to.html

 
At September 14, 2013 at 2:38 AM , Anonymous Anonymous said...

hey could you explain please why you use remove method and formsauthentication.signout() method?
will it not work only with session.abandon()?

 
At September 16, 2013 at 9:34 PM , Anonymous Anonymous said...

I used your login code...but i want to know that after successfully logging in ,whether the details goes into login database or it only read the data from signup database ...

also, when i logged in to the account,it directs me to home page..but i want that instead of showing login button page..it should show signed in username..wat should i do? please help me sir...

 
At September 16, 2013 at 9:34 PM , Anonymous Anonymous said...

This comment has been removed by a blog administrator.

 
At September 16, 2013 at 9:46 PM , Blogger Developers Code said...

Hi,

No it will not store the login information.its just checking the records . if want u to store login information check this tutorial

http://www.developerscode.com/2013/01/track-user-login-information-using.html

Please let me know if you any queries.

 
At February 17, 2015 at 5:35 PM , Blogger Unknown said...

Your Code is very simple ..thanks

 

Post a Comment

Subscribe to Post Comments [Atom]

<< Home