microcipcip / cookie-universal

Universal cookie plugin, perfect for SSR
525 stars 39 forks source link

how set expire times? #61

Closed sohepalslamat closed 4 years ago

microcipcip commented 4 years ago

You can either use maxAge or expires, they are all properly documented in the library set or setAll methods.

 cookies.set('cookie-name', 'cookie-value', {
    path: '/',
    maxAge: 60 * 60 * 24 * 7
  })

Or

 cookies.set('cookie-name', 'cookie-value', {
    path: '/',
    expires: new Date('2020-06-01')
  })