Click here to Skip to main content
16,020,990 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
when i login with my credentials after that i copy the URl and now i logout from that and past the copy URL here it goes to my login page.How to resolve it.



In Login
string username = txtusr.Value;
XML
Session["user"] = list.Count();
                if (list.Count == 0)
                {
                    Response.Redirect("Home.aspx");
                }
                else
                {
                    Response.Redirect("details.aspx?username=" + username);
                }

when logout i'm using

<pre lang="cs">Session.Contents.RemoveAll();
Session.Abandon();
Session.Remove(&quot;user&quot;);</pre>
Posted
Comments
Harpreet Singh 15-May-15 3:56am    
Session.Clear();
Session.Abondon();

1 solution

The Abandon method should work (MSDN):

C#
Session.Abandon();

If you want to remove a specific item from the session use (MSDN):

C#
Session.Remove("YourItem");

EDIT: If you just want to clear a value you can do:

C#
Session["YourItem"] = null;

If you want to clear all keys do:

C#
Session.Clear();


Quote:
// if forms auth is used

C#
<blockquote class="quote"><div class="op">Quote:</div>HttpContext.Current.Session.Clear();
HttpContext.Current.Session.Abandon();
HttpContext.Current.User = null;
System.Web.Security.FormsAuthentication.SignOut();</blockquote>
 
Share this answer
 
v2
Comments
[no name] 17-May-15 21:33pm    
updated form auth and if that doesn't work please refer the below link

http://stackoverflow.com/questions/9766804/how-to-kill-the-session-of-user-when-he-loggedout-in-asp-net

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