3

Do you know if a Javascript library to handle cookies exists, that is mature and can work without a browser? In other words I only want the cookie logic that is included in the web browsers and HTTP clients and following the current standards, and the cookies are stored and retrieved from a private store.

I think the library can only contain get/set methods. The set method set cookies that came from the "Set-Cookie" HTTP header and the get method returns a list of cookies to send in the "Cookie" header for a specific host (or domain). The get method would need to receive a host as a parameter too, since return an error or something if a host is specifying cookies for another domain. There are more details about cookies that can be nice to have.

I saw questions like Is there an equivalent to the Apache HTTP Client in JavaScript? but the answer works and sets the cookie within a browser and not in a specific container.

Note: I looked into https://github.com/jed/cookies/blob/master/lib/cookies.js , it is the closer library that matches the question right now. The most important issue against it is that there is not a getter for a domain: imagine you want to return all cookies for the yahoo.com domain, this logic is not part of the library and it is one of the most important features for a cookie library to decide which cookies to send in an HTTP request.

Community
  • 1
  • 1
sw.
  • 3,240
  • 2
  • 33
  • 43
  • So essentially you want an app that can query a Web site and do nothing but store and retrieve its cookies? – ameed Apr 12 '13 at 21:35
  • From the functional aspect yes. It can receive cookies from many web sites and when a connection is established can decide which cookies to sent based on the standards. – sw. Apr 12 '13 at 21:39
  • Does libcurl's cookie jar do what you want? – Barmar Apr 21 '13 at 05:48
  • @Barmar it is not written in Javascript. – sw. Apr 21 '13 at 15:00

2 Answers2

1

I found a library that answers my question: CookieJar for Node (not bound to HTTP requests). Take into account that the @Barmar comment was related to cookie jar on libcurl.

I found the lib using the following query: site:github.com cookies lib domain secure

sw.
  • 3,240
  • 2
  • 33
  • 43
0

Have you looked at Cookies.js yet? It claims to be client-side AND cross-browser.

Mark Leighton Fisher
  • 5,609
  • 2
  • 18
  • 29
  • Yes, I don't think it works. The code is using with the document.cookie and even if there is a cache inside the code assigning a cookie document.cookie does many things internally (in the browser) that are not handled by this library. – sw. Apr 21 '13 at 15:02