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.
Asked
Active
Viewed 1,032 times
0
-
1Keep the credentials in local storage. – Lazar Ljubenović Sep 20 '18 at 04:40
-
Possible duplicate of [Cookie Authentication expiring too soon in ASP.NET Core](https://stackoverflow.com/questions/45595615/cookie-authentication-expiring-too-soon-in-asp-net-core) – mjwills Sep 20 '18 at 04:56
1 Answers
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