๐ช Cookie utilities
This section of the package focuses on cookies and how to integrate them with your Worker.
warning
Be aware that cookie.jar will not set existing cookies when doing setHeaders
. Browsers will keep cookies until they expire so we felt this was un-necessary to keep setting existing cookies.
cookie.jar(request: Request or Null)
Returns a new CookieJar object. This allows you to read the request's cookies or set your own. Be aware that cookies read from the request wont be saved by default. If you want to send the cookies that were sent with the request back, you need to iterate over the cookies and add them to the CookieJar.
CookieJar.get(key: String)
Returns the cookies value, or it will return an empty string if no value was found.
CookieJar.set(key: String, value: String, options: Object)
Sets the cookie value. Returns null
.
The options object accepts values for the cookie. For example, you can set the secure mode via { secure: true }.
info
If you want to append your cookies to a response, you can slot the CookieJar object into any of easy-util's response helpers.