0

I am making a web app and when a user logs out and is taken to the login page, I want to stop them from being able to go back to the previous page (the logged in page) as they just logged out and this would be a security issue? I was wondering who I could do this in JavaScript? I would like it ideally to just reload the current page they are on the first time they hit it and then if they hit it a second time go to the last page where they weren't logged in. Or if thats not possible then to do what the standard practice is?

Here is what I am trying but its not working,

<script type="text/javascript">
onload=function(){
    console.log('called')
e=document.getElementById("refreshed");
if(e.value=="no")e.value="yes";
else{e.value="no";location.reload();}
}
</script>

I get an error saying e is not defined

spen123
  • 2,934
  • 10
  • 34
  • 50

1 Answers1

0

You can either prevent the page from getting cached in the client. Or perform an ajax request on page load to check if user is logged in, in the backend and if not refresh the page.

Community
  • 1
  • 1
lorefnon
  • 12,112
  • 4
  • 54
  • 87