3 * Connect - session - Cookie
4 * Copyright(c) 2010 Sencha Inc.
5 * Copyright(c) 2011 TJ Holowaychuk
10 * Module dependencies.
13 var utils = require('../../utils');
16 * Initialize a new `Cookie` with the given `options`.
18 * @param {Object} options
22 var Cookie = module.exports = function Cookie(options) {
25 this.maxAge = 14400000;
26 if (options) utils.merge(this, options);
27 this.originalMaxAge = undefined == this.originalMaxAge
29 : this.originalMaxAge;
47 this.originalMaxAge = this.maxAge;
62 * Set expires via max-age in `ms`.
69 this.expires = 'number' == typeof ms
70 ? new Date(Date.now() + ms)
75 * Get expires max-age in `ms`.
82 return this.expires instanceof Date
83 ? this.expires.valueOf() - Date.now()
88 * Return cookie data object.
96 originalMaxAge: this.originalMaxAge
97 , expires: this._expires
99 , httpOnly: this.httpOnly
100 , domain: this.domain
106 * Return a serialized cookie string.
112 serialize: function(name, val){
113 return utils.serializeCookie(name, val, this.data);
117 * Return JSON representation of this cookie.