0

In angular, I have used 'ng-idle' package to logout inactive logins. I have used 'ng-idle' package in two different applications. When I open one application in browser at a time then its working properly. But when I open those two applications in two different tabs of same browser, then one of them is not getting logout during inactivity.

My code snippet (just basic snippet for information):

Application 1:

import { Idle, DEFAULT_INTERRUPTSOURCES } from '@ng-idle/core';
import { Keepalive } from '@ng-idle/keepalive';

constructor(private idle: Idle, private keepalive: Keepalive) {
   idle.setIdleName('app1');
   idle.setIdle(5);
   idle.setTimeout(1);
   idle.setInterrupts(DEFAULT_INTERRUPTSOURCES);

   idle.onIdleEnd.subscribe(() => this.idleState = 'No longer idle.');
   idle.onTimeout.subscribe(() => {
       //logout related script logic
   });

   keepalive.interval(15);
}

Application 2:

import { Idle, DEFAULT_INTERRUPTSOURCES } from '@ng-idle/core';
import { Keepalive } from '@ng-idle/keepalive';

constructor(private idle: Idle, private keepalive: Keepalive) {
   idle.setIdleName('app1');
   idle.setIdle(30);
   idle.setTimeout(1);
   idle.setInterrupts(DEFAULT_INTERRUPTSOURCES);

   idle.onIdleEnd.subscribe(() => this.idleState = 'No longer idle.');
   idle.onTimeout.subscribe(() => {
       //logout related script logic
   });

   keepalive.interval(15);
}

Same way, I have used 'ng-idle' in another app with 'idle.setIdleName('app2')'

It works properly when I open one app at a time. But do not work when I open both applications in separate tabs of same browser. One app is not getting logout during inactivity.

Difference in both applications scripts is: idle.setIdle(5); >> idle.setIdle(30);

Please suggest me solution on this.

Rakesh Hiray
  • 721
  • 3
  • 15

0 Answers0