You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

44 lines
1.1 KiB

7 years ago
  1. # cookie [![Build Status](https://secure.travis-ci.org/defunctzombie/node-cookie.png?branch=master)](http://travis-ci.org/defunctzombie/node-cookie) #
  2. cookie is a basic cookie parser and serializer. It doesn't make assumptions about how you are going to deal with your cookies. It basically just provides a way to read and write the HTTP cookie headers.
  3. See [RFC6265](http://tools.ietf.org/html/rfc6265) for details about the http header for cookies.
  4. ## how?
  5. ```
  6. npm install cookie
  7. ```
  8. ```javascript
  9. var cookie = require('cookie');
  10. var hdr = cookie.serialize('foo', 'bar');
  11. // hdr = 'foo=bar';
  12. var cookies = cookie.parse('foo=bar; cat=meow; dog=ruff');
  13. // cookies = { foo: 'bar', cat: 'meow', dog: 'ruff' };
  14. ```
  15. ## more
  16. The serialize function takes a third parameter, an object, to set cookie options. See the RFC for valid values.
  17. ### path
  18. > cookie path
  19. ### expires
  20. > absolute expiration date for the cookie (Date object)
  21. ### maxAge
  22. > relative max age of the cookie from when the client receives it (seconds)
  23. ### domain
  24. > domain for the cookie
  25. ### secure
  26. > true or false
  27. ### httpOnly
  28. > true or false