title: How to implement *Remember me* option using Amazon Cognito sdk?
body: <p>I am trying to implement a <em>Remember Me</em> option for authentication workflow using <em>amazon-cognito-identity-js</em> in Angular2 project. <a href="https://github.com/awslabs/aws-cognito-angular2-quickstart/issues/119" rel="noreferrer">Issue reference</a>.</p>
  
  <p><strong>Current authentication flow</strong></p>
  
  <ol>
  <li>If <em>Remember me</em> option is checked then save token and JWT token(specially do this because I need some other user info such as groups and roles) to cookie with expiration date. (ex : 5 days )</li>
  <li>Auth guard (that is checking all routing changes even if root routing) will check token(not JWT) first</li>
  <li>If cookie is empty then redirect to Login page.</li>
  <li>If cookie exists then check session(using function of sdk), session is invalid then redirect to Login page.</li>
  <li>If session is valid then update JWT(not token) and guard returns true.</li>
  </ol>
  
  <p>I think it seems fine, but I am getting some unexpected errors, not often but once 1 hour has passed (actual session expired).</p>
  
  <p><strong>Questions</strong></p>
  
  <ol>
  <li>Do I have to update token as well? At <code>step 5</code>.</li>
  <li>Is <code>this.cognitoUtil.getCurrentUser();</code> asynchronous function?</li>
  <li>What will be returned from <code>cognitoUser.getSession()</code> if session is expired?</li>
  <li>If <em>Ques 3</em> returns session (even if it is valid or invalid), what is the returning value of <code>session.isValid()</code>?</li>
  </ol>