title: determine when cookie will expire with node Request module
body: <p>I'm writing an app that builds an API through scraping an external domain. In order to scrape the domain, my server must be authorized ( with a session cookie ).</p>
  
  <p>I'm using the <a href="https://github.com/request/request" rel="nofollow noreferrer">request module</a> with a cookie jar to maintain the cookies across requests.</p>
  
  <p>I want to set up some Node router middleware so that, if/when the session expires, I can re-run my authentication method. Think something like this:</p>
  
  <pre><code>export function validate(req, res, next) {
      const cookie = cookieJar.getCookie('**target domain**');
      const COOKIE_IS_EXPIRED = // ???
      if ( COOKIE_IS_EXPIRED ) {
          authenticate().then(next);
      } else {
          next();
      }
  }
  </code></pre>
  
  <p>When I log out the contents of <code>cookieJar.getCookies()</code> my result is something like the following:</p>
  
  <pre><code>[ Cookie="lw_opac_1=1483019929431275955; Expires=Wed, 29 Mar 2017 13:58:49 GMT; Max-Age=7776000; Path=/opac; hostOnly=true; aAge=0ms; cAge=6345ms",
    Cookie="lw_opac=ta4tscsejs6c94ngikt7hlbcn0; Path=/; hostOnly=true; aAge=0ms; cAge=6347ms" ]
  </code></pre>
  
  <p>how can I validate when that both cookies are close to / have expired, and then re-run my auth function?</p>
  
  <p>Thanks!</p>