title: How to make login status persistent in Angular 2/3/4/5
body: <p>I am currently using a token (aka session ID) in my Angular 5 application where I pass it to the back end in a request header like this;</p>
  
  <pre><code>const headersForJSON: HttpHeaders = new HttpHeaders (
    {
      'Content-Type': 'application/json',
      'Accept': 'application/json'
    }
  );
  </code></pre>
  
  <p>which is used with each request.   If client has a token (i.e. the user is logged in) then I add another header like this;</p>
  
  <pre><code>this.headers = headersForJSON.set("Authorization", v.authtoken);
  </code></pre>
  
  <p>This works perfectly unless the user reloads the application or manually modifies the URL in the browser. Also if the user right-clicks a router link to open another window/tab into the application.</p>
  
  <p>In these cases the Angular SPA environment is lost and the <strong>authtoken</strong> variable is undefined so there is nothing to send to the back end. </p>
  
  <p>Is there a standard practice for fixing this?</p>