javascriptphpcookiessession-cookies

Alternative for document.cookie in JavaScript


Any JavaScript code, other than "document.cookie" to view all the cookies in the browser?


Solution

  • document.cookie is for getting/setting cookies - that's what you should use...

    There is an alternative for local storage with javascript, which is conveniently called localStorage and sessionStorage.

    If you're looking for a library to make it easier to work with document.cookie, perhaps you'd be interested in this: jQuery Cookie (click). Even better, MDN has a little library for working with cookies in these docs (click) (no need for jQuery).