I created a Session on myProfile.aspx when page loads. I put a hyperlink who navigate to logout.aspx and on logout's page load I wrote Session.Clear() & Session.Abandon(). But when i click on the Back button of the browser then the session's
value still display. How to clear that value?
That must be done in ever page so there are 2 Solutions, 1st for code behind, 2nd for HTML source
but if the thing is not done, you can use both at once, on every page
Silverlight....
Member
431 Points
373 Posts
How to clear session value?
Dec 31, 2012 05:29 AM|LINK
Hi All,
I created a Session on myProfile.aspx when page loads. I put a hyperlink who navigate to logout.aspx and on logout's page load I wrote Session.Clear() & Session.Abandon(). But when i click on the Back button of the browser then the session's value still display. How to clear that value?
kedarrkulkar...
All-Star
35557 Points
5696 Posts
Re: How to clear session value?
Dec 31, 2012 05:33 AM|LINK
read this
http://www.dotnetspider.com/resources/29215-How-solve-back-button-problem-after-logout.aspx
or disable back button on login page
http://zeeshanumardotnet.blogspot.com/2010/06/how-do-disable-back-button-in-browser.html
hope this helps...
KK
Please mark as Answer if post helps in resolving your issue
My Site
alankarp
Contributor
2042 Points
345 Posts
Re: How to clear session value?
Dec 31, 2012 05:34 AM|LINK
Please see below URL
http://www.codeproject.com/Articles/11225/Disabling-browser-s-back-functionality-on-sign-out
Hope this will help you
Profile
senthilwaits
Contributor
3832 Points
651 Posts
Re: How to clear session value?
Dec 31, 2012 05:43 AM|LINK
Please refer - http://forums.asp.net/t/1865113.aspx/1?Logout+Issue+
That's because the browser takes the page from cache. So even if you logout, the browser back/forward buttons can get the page from cache.
Add the below code to your pages so those will not get cached on the browser.
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { Response.Cache.SetExpires(DateTime.UtcNow.AddDays(-1)); Response.Cache.SetCacheability(HttpCacheability.NoCache); Response.Cache.SetNoStore(); } }Senthil Kumar Sundaram
usman400
Contributor
3493 Points
721 Posts
Re: How to clear session value?
Dec 31, 2012 05:46 AM|LINK
That must be done in ever page so there are 2 Solutions, 1st for code behind, 2nd for HTML source
but if the thing is not done, you can use both at once, on every page
Response.Cache.SetExpires(DaeTime.UtcNow.AddMinutes(-1));
Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.Cache.SetNoStore();
usman400
Contributor
3493 Points
721 Posts
Re: How to clear session value?
Dec 31, 2012 05:47 AM|LINK
Second is through HTML source using meta tages
sameer_khanj...
Star
7504 Points
1466 Posts
Re: How to clear session value?
Jan 02, 2013 06:38 AM|LINK
On Logout Page Load
protected void Page_Load(object sender, EventArgs e) { //RegisterHyperLink.NavigateUrl = "Register.aspx?ReturnUrl=" + HttpUtility.UrlEncode(Request.QueryString["ReturnUrl"]); Response.ClearHeaders(); Response.Cache.SetExpires(DateTime.UtcNow.AddDays(-1)); Response.Cache.SetCacheability(HttpCacheability.NoCache); Response.Cache.SetNoStore(); Response.AddHeader("Cache-Control", "no-cache, no-store, max-age=0, must-revalidate"); Response.AddHeader("Pragma", "no-cache"); Session.Clear(); Session.Abandon(); }sameer.khanjit@gmail.com
View Blog
Click "Mark as Answer" on the post that helped you.
nikunjnandan...
Participant
882 Points
223 Posts
Re: How to clear session value?
Jan 04, 2013 06:19 AM|LINK
Hiii
Are you using form authentication?
If yes then you also try with
FormsAuthentication.SignOut()Session("User") = Nothing ' Your session varibale do it nothing.if it C# then null Session.Clear() Session.RemoveAll()Nikunj Nandaniya
My Blog