0

there is a special scenario I need to solve, that is when a user try to access the system directly using a new tab of browser while open in a another browser without go through login page or other pages, user should be redirected to the login page.

for this issue I am expecting a solution from any of following technologies

  • javascript

  • angular

  • jquery

following behavior I tried, but failed that way because java script variables are reset when reload the page as well rather than open a new tab and access variable value.

Do browsers propagate javascript variables across tabs?

Buddhika Alwis
  • 373
  • 14
  • 23
  • 3
    What exactly do you store for session management on the front-end when the user logs in? You should try to have a look at Route Guards, `CanActivate` Guard to be specific. – SiddAjmera Jul 14 '19 at 12:18
  • you can use ```sessionStorage``` instead of ```localStorage```. Local storage is persisted until you intentionally remove it and it's shared to new tabs. But if you store your data in sessionStorage, they would be there only until that tab or browser closes and they won't be shared with other tabs. And it won't be destroyed if your refresh current tab. – Dilan Tharaka Jul 14 '19 at 16:18
  • 1
    The article you mentioned in your question uses ```localStorage```. Just replace it with ```sessionStorage```. You may find more details about the difference between ```localStorage``` and ```sessionStorage``` in this question, https://stackoverflow.com/questions/5523140/html5-local-storage-vs-session-storage – Dilan Tharaka Jul 14 '19 at 16:26
  • @DilanTharaka and SiddAjmera these solutions are acceptable, thank you very much for answers – Buddhika Alwis Jul 14 '19 at 16:36

0 Answers0