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..
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..
Labels: Aspnet, Authentication, C#, CSharp, Custom Controls, Sessions, Tanisha
8 Comments:
Its very simple thanks,
can i hav the link to the page wher u hav explained hw to login using sessions...thaks
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
hey could you explain please why you use remove method and formsauthentication.signout() method?
will it not work only with session.abandon()?
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...
This comment has been removed by a blog administrator.
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.
Your Code is very simple ..thanks
Post a Comment
Subscribe to Post Comments [Atom]
<< Home