theodorejb / es-cookie

A simple, lightweight module for handling cookies
MIT License
45 stars 2 forks source link

Missing cookie attributes #3

Closed angeloashmore closed 5 years ago

angeloashmore commented 6 years ago

Nice library! I really like the simplicity.

Is there any reason some of the attributes present in RFC 6265 were left out of CookieAttributes?

List taken from universal-cookie:

httpOnly and maxAge are not present in CookieAttributes. I don't use TypeScript, so I'm not sure if the compiled code excludes any additional properties not listed in the interface.

theodorejb commented 6 years ago

The expires property allows either a date or a number to be passed to choose a relative expiration, so I don't think a separate maxAge option is necessary.

As I understand it, the HttpOnly attribute prevents cookies from being accessed via document.cookie (which this library uses). I'm not sure there's a way to create a cookie on the client-side that can then only be accessed on the server.

jsommr commented 5 years ago

I think this issue can be closed. There's no way to set httpOnly and expires seems to already be taken care of. See https://github.com/carhartl/jquery-cookie/issues/122 and https://stackoverflow.com/questions/14691654/set-a-cookie-to-httponly-via-javascript regarding httpOnly.