Closing pop-ups when session expires

Here's what: my webapp has a lot of pop-ups, and my boss wants them to be closed after the session expires, when the session expires, and the user clicks on the update in the pop-up window, they show him the login page → user logs → user goes to the dashboard. Now the toolbar screen in the pop-up window is completely unnecessary. This is where google got me:

I have javascript to close a popup. Generate this onload script in response if the session has expired (checking session end with jsp and enabling onload script conditionally).

Do you think this is a good way? What is the best practice for this scenario?

PS: I am not allowed to use AJAX

+3
source share
5 answers

In a past life, I created a popup manager object that supported which windows were open. You should probably do one of these, if not already done. Then you can use setTimeoutto call the function after so many minutes have passed (or as much as you like). This will check the current activity (possibly through AJAX) and close the popup if you determine that the session has expired. If not, call setTimeoutagain with a new time appropriately configured for the most recent activity.

^^ before editing AJAX.

, AJAX, - URL-, , ? , , .

+1

- XMLHTTP , , - .

( ) , AJAX, , , , , AJAX, .

+1

, AJAX, . , , ( ), - javascript ( ajax).

- script , , 30 .

setInterval(function(){
  $.get("loggedin.php", function(result) {
    if (!result.isLoggedIn)
      window.close();
  });
}, 30000);

script , jQuery javascript-. JSON (Javascript Object-notation) loggedin.php.

AJAX. , . , .

+1

-:

  • DIV, : none;
  • / Modal DIV
  • Reset CSS, DIV , , z-index CSS

, , ​​ . , , . AJAX.

, - . Yahoo. (IE: ), AJAX, .

.

+1

AJAX, -...

, AJAX - "" , , , , " AJAX", , AJAX - .

Does he think AJAX will take too much time to implement? If so, you must prove to him that he is mistaken. Does he think it will be difficult to maintain? If so, show how simple this code will be and how widely used AJAX libraries are common. If your boss is smart, then his goal is what works best for the product, and you should be able to reason with him.

0
source

Source: https://habr.com/ru/post/1713720/


All Articles