One pattern in the JavaScript API world that web development veterans will notice is that we’ve been creating new methods to accomplish what older, grosser APIs once achieved. XMLHttpRequest
became the fetch
API, some APIs like Battery became async, and there are dozens of other examples. Another API desperately in need of updating is the cookie API…and we’ve finally got it: cookieStore
.
The new cookie API, cookieStore
, is asynchronous and provides a logical method for cookie management. You have to remember that the previous method of getting and setting cookies completely revolved around concatenating and parsing document.cookie
as a string. Don’t believe me? Check out this monstrosity!
document.cookie =
'__Secure-COOKIENAME=cookie-value' +
'; Path=/' +
'; expires=Fri, 12 Aug 2016 23:05:17 GMT' +
'; Secure' +
'; Domain=example.
Check Full Content Here [...]
from Proven Ways https://provenways.com/cookiestore-async-cookie-api/
Comments
Post a Comment