0

We are using the dot net core 2.1, with angular 5. We save the user id and user name etc info in sessions for authentication. But the problem is, after sometime the system gets the user logged out. Although, we make some server side requests during that time. Is there any way to keep the session alive, until the browser session regardless if user makes some server side or not. Even if the user makes server side request, when open the ink in new tab it will ask to login again.

1 Answers1

0

Save credential in local storage. Below is the angular code example

import { Injectable } from '@angular/core';
import { TokenType } from './tokenResponseType';

@Injectable()
export class TokenManager {

  private _tokenKey: string = 'bapp_key';

  storeToken(tokenDetail: TokenType) {
    localStorage.setItem(this._tokenKey, JSON.stringify(tokenDetail));
  }

  getToken() {
    var tokenDetails = localStorage.getItem(this._tokenKey);
    return JSON.parse(tokenDetails);
  }
}
bhathiya.m
  • 215
  • 2
  • 12