如何使用cookie(request,tough-cookie,node.js)

我想知道如何使用cookie与请求 ( https://github.com/mikeal/request )

我需要设置一个可以从请求中获取每个子域的cookie,

就像是

* .examples.com

path是每个页面,就像

/

那么服务器端就可以正确地从cookie中获取数据,就像

testing= 1234

我发现从响应安装的cookie工作正常,

我添加了一个自定义的jar来保存cookie,就像

var theJar = request.jar(); var theRequest = request.defaults({ headers: { 'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/34.0.1847.116 Safari/537.36' } , jar: theJar }); 

但我从请求设置的cookie,只能在同一个域中获取,

我无法find一个方法来设置cookie更多的选项

现在,如果我想要一个能够在三个子域中获取的cookie,

我必须这样设置:

 theJar.setCookie('test=1234', 'http://www.examples.com/', {"ignoreError":true}); theJar.setCookie('test=1234', 'http://member.examples.com/', {"ignoreError":true}); theJar.setCookie('test=1234', 'http://api.examples.com/', {"ignoreError":true}); 

在这里有任何提前的方式来从请求设置cookie,

使它能够在每个子域中获取?

我刚刚find解决scheme….

 theJar.setCookie('test=1234; path=/; domain=examples.com', 'http://examples.com/'); 

嗯…我不得不说,请求的文件不是那么好…,哈哈