I have an web application which requires login. When users finish their activities they simply logout. What I need is to clear browser history when user click logout button. This should disable BACK button in browser.
But if the problem is, that if the user clicks back after they have logged out, they can just go straight back onto the page, is it not possible to manually type the address in the address bar and get to the page, whether the back button is disabled or
not?
Without going as far as using Secure connections etc. you could just pop a check ontop of your 'Logged in only' pages to see if the Session has something for the current User. Then when you log out, you clear the session.
Thanks ;) I use it in a page called clearhist.aspx. All the pages that require no back button are routed through this page with the nextpage as a query variable.
I use it for logging out too and bringing user back to Login page:
Protected
Sub btnLogOut_Click(ByVal sender
As Object,
ByVal e As System.EventArgs)
Handles btnLogOut.Click
Session.Abandon()
FormsAuthentication.SignOut()
Dim nextpage
As String =
"../tgvf_login.aspx"
Response.Write("<SCRIPT LANGUAGE=javascript>")
Response.Write(
"{")
Response.Write(" var Backlen=history.length;")
hi, i am working on an asp page. i tried with your code but it redirected me to the home page instead of the given URL mentioned in "window.location.href". is there any option that we can delete a specific page from browser history on page unload or when
we close the window. kindly request you to provide help for asp.
marko.pa
Member
567 Points
237 Posts
can javascript clear browser history?
Jul 11, 2007 09:02 PM|LINK
Hi,
I have an web application which requires login. When users finish their activities they simply logout. What I need is to clear browser history when user click logout button. This should disable BACK button in browser.
Thanx!
Haissam
All-Star
37421 Points
5632 Posts
Re: can javascript clear browser history?
Jul 11, 2007 10:08 PM|LINK
i dont think you can clear the client browser history from javascript. anyhow check below link
A thorough examination of "disabling back button"
HC
MCAD.NET
| Blog |
marko.pa
Member
567 Points
237 Posts
Re: can javascript clear browser history?
Jul 15, 2007 09:50 AM|LINK
I tried, but it does not go so easy! Maybe I should use secure connection.
I am going to leave this post as "not resolved" for some time.
Thanx anyway!
Marko
sreejukg
All-Star
28141 Points
4206 Posts
Re: can javascript clear browser history?
Jul 15, 2007 12:50 PM|LINK
My Blog
kris860911
Member
56 Points
16 Posts
Re: can javascript clear browser history?
Jul 16, 2007 11:12 AM|LINK
But if the problem is, that if the user clicks back after they have logged out, they can just go straight back onto the page, is it not possible to manually type the address in the address bar and get to the page, whether the back button is disabled or not?
Without going as far as using Secure connections etc. you could just pop a check ontop of your 'Logged in only' pages to see if the Session has something for the current User. Then when you log out, you clear the session.
sanjayd
Member
170 Points
55 Posts
Re: can javascript clear browser history?
Jul 16, 2007 11:20 AM|LINK
I think it can doSanjay D.
eseidel
Participant
1607 Points
505 Posts
Re: can javascript clear browser history?
Jul 16, 2007 05:16 PM|LINK
Yes, you can clear browser history through javascript....
//clears browser history and redirects url
<SCRIPT LANGUAGE=javascript> { var Backlen=history.length; history.go(-Backlen); window.location.href=page url}
</SCRIPT>
Eric
robnot
Member
216 Points
99 Posts
Re: can javascript clear browser history?
Jul 16, 2007 07:37 PM|LINK
That is a wicked trick, Eric :)
eseidel
Participant
1607 Points
505 Posts
Re: can javascript clear browser history?
Jul 16, 2007 07:53 PM|LINK
Thanks ;) I use it in a page called clearhist.aspx. All the pages that require no back button are routed through this page with the nextpage as a query variable.
I use it for logging out too and bringing user back to Login page:
Protected Sub btnLogOut_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnLogOut.ClickSession.Abandon()
FormsAuthentication.SignOut()
Dim nextpage As String = "../tgvf_login.aspx" Response.Write("<SCRIPT LANGUAGE=javascript>")Response.Write(
"{") Response.Write(" var Backlen=history.length;")Response.Write(
" history.go(-Backlen);") Response.Write(" window.location.href='" & nextpage & "'; ")Response.Write(
"}") Response.Write("</SCRIPT>") End SubEric
ipshita_11
Member
2 Points
12 Posts
Re: can javascript clear browser history?
Jun 24, 2009 06:28 AM|LINK
hi, i am working on an asp page. i tried with your code but it redirected me to the home page instead of the given URL mentioned in "window.location.href". is there any option that we can delete a specific page from browser history on page unload or when we close the window. kindly request you to provide help for asp.
ASP