JillElaine / jquery-idleTimeout

Idle activity timeout and logout redirect for jQuery for multiple windows & tabs
Other
72 stars 79 forks source link

How to make idle-timeout script work across subdomains #24

Closed amitvit2002 closed 8 years ago

amitvit2002 commented 8 years ago

Hi Jil,

I am trying to use this plugin within my site, I have 3 sub-domains within same domain and we use mcp within these for session affinity.

https://qa.bnymellonwealthmanagement.com https://qa-reports.bnymellonwealthmanagement.com https://apps-qa.bnymellonwealthmanagement.com

I opened a page hosted on https://apps-qa.bnymellonwealthmanagement.com from https://qa.bnymellonwealthmanagement.com domain but idle timeout popup is only coming on https://qa.bnymellonwealthmanagement.com. Its not coming on https://apps-qa.bnymellonwealthmanagement.com/..

My use case is if I am working on https://apps-qa.bnymellonwealthmanagement.com page on new browser or tab, page at https://qa.bnymellonwealthmanagement.com timesout and open idle timeout pop but same is not getting reflected on https://apps-qa.bnymellonwealthmanagement.com page and I am getting timed out even I am active on https://apps-qa.bnymellonwealthmanagement.com. Please help.

Also what I need to do to customize (text, font, color) warning dialog box?

Appreciate your help.

JillElaine commented 8 years ago

To allow localStorage to communicate across subdomains within the same parent domain, please try to 'relax' the 'same origin' policy. https://en.wikipedia.org/wiki/Same-origin_policy#Relaxing_the_same-origin_policy and https://developer.mozilla.org/en-US/docs/Web/Security/Same-origin_policy#Changing_origin

Hopefully you can find a solution to relax the same origin policy so that windows & tabs from your parent and subdomains can communicate via localStorage. There is no need to modify the jquery-idleTimeout script.

Please report back about the subdomains issues, and let me know how that works, so we can all learn from your experience.

As for modifying the CSS for the dialog box, create your own custom theme css files for JQuery UI or use one of the ready-made themes from the Gallery with the ThemeRoller online application: http://jqueryui.com/themeroller/

amitvit2002 commented 8 years ago

Hi Jil,

Thanks for quick reply. Let me explore that. One more question, how can we focus browser when dialog opens to let user know that he is timing out if he is working on another browser window. I mean browser icon in taskbar should start blinking or highlighting once dialog opens. That way user will be notified, I was working on word and realized I have open site 10 mins back with 5 mins as idle timeout setting. When I went back I was already timed out, any focus should have helped me renewing my session.

JillElaine commented 8 years ago

You could try adding the window.focus() method to the function that opens the warning dialog box. See below.

    openWarningDialog = function () {

      var dialogContent = "<div id='idletimer_warning_dialog'><p>" + currentConfig.dialogText + "</p><p style='display:inline'>" + currentConfig.dialogTimeRemaining + ": <div style='display:inline' id='countdownDisplay'></div></p></div>";
...snipped...
      document.title = currentConfig.dialogTitle;

       window.focus();  // add this line to the openWarningDialog function.

      if (currentConfig.sessionKeepAliveTimer) {
        stopKeepSessionAlive();
      }
    };

Let me know if that works as you wish.

amitvit2002 commented 8 years ago

I tried this and also tried window.moveTo(0,0) but both didn't work. :(

JillElaine commented 8 years ago

Hmmm, you might read this thread. Sounds like there may be issues getting something to work with all browsers. Report back if you get something to work. It would be a good feature to add to the plugin. http://stackoverflow.com/questions/37122/make-browser-window-blink-in-task-bar

JillElaine commented 8 years ago

Any news on making the script work across subdomains, amitvit2002?