-1

there are lot questions similar to this question and many answers too. But all the answers are saying similar thing. Hence please help me with this. Problem : When user closes tab or browser then i want to destroy session. solutions tried : I have tried following in jquery. - onbeforeunload() : destroy session using ajax. But it works even on refresh of page. - setting flag=1 on load() and flag=0 on unload() updating in db. But session wont be destroyed. - set session time out. But before session time out if they open then it will be logged in. Hence i want some solution that over rides all these restrictions and works like bank apps or some security apps.

Thanks in advance.

Pratima
  • 95
  • 2
  • 9
  • 2
    If you want any concrete help with your code, you will have to show us your actual code. That's how it works here. Questions about code MUST include your code. And, just so you know, there are NO 100% foolproof schemes that are client driven. Ultimately you will have to timeout the session on your server after some period of inactivity. That is the only completely reliable way to do it. You can use client schemes to give the server hints, but the server has to backstop things with a server-based timeout when the client fails to follow the rules (which it does sometimes). – jfriend00 Jul 15 '16 at 05:55
  • [Try this link](http://stackoverflow.com/questions/8323346/how-to-delete-cookie-in-jquery-at-the-time-of-browser-closing) Try this link......... – Ranjan Jul 15 '16 at 06:13

1 Answers1

1
window.onbeforeunload = function() {...
Ranjan
  • 929
  • 1
  • 6
  • 19
  • The OP already noted the use of `onbeforeunload`, but the question is more complex. You probably should edit your answer and add additional information to it, like how this helps, what this does and what follows the ellipsis. – dakab Jul 15 '16 at 07:51