Log out in new ASP Classic tab

Asked

Viewed 182 times

0

It is possible to close the session of ASP when opening a new tab?

I am trying to end the login session of ASP when the user opens another tab and tries to access the system, the idea is that the system can only be accessed by a tab, if the user tries to open in another tab, will close all sessions of ASP.

I tried to use JS with the localStorage to block this, but did not work (does not run)

response.write "<script>"
response.write "var url = window.location.href; "
response.write "var key = Math.floor((Math.random() * 999999999) + 1); "
response.write "if(!localStorage.session){ localStorage.setItem('session', key) }else{  window.location.href = 'MultiplasSecoes.asp'}; "
response.write "if(!localStorage.url){ localStorage.setItem('url', url) };"
response.write "alert(localStorage.session) "
response.write "</script>"

I also tried to put in mine index

if session("SESSAO_ABERTA") = true then
  response.write "<script>"
  response.write "location.href = 'MultiplasSecoes.asp';"
  response.write "</script>"

else
    'response.write "<script>alert()</script>"
    session("SESSAO_ABERTA_ECARGO") = true
end if
  • How will you know if it’s a new tab or just a refresh?

  • @Leandroangelo I think it doesn’t matter so much, since it will be in the index, then if it goes back to index, you can finish the sessions as well. as long as it already exists. (if you have any better tips)

  • Session.Abandon... but then it would only drop if the user went to index.Asp

  • This is going to be tricky.. as @Leandroangelo commented, I can’t think of how you’ll know if the user came from another tab... And if every time you enter index.Asp and you delete the session will go into infinite loop!!! Imagine it enters the index and already has session, you delete and directs to login for example, after returning to index, will delete again and will never end!

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.