I want http://mydomain.com to be the same as http://www.mydomain.com
我希望http://mydomain.com与http://www.mydomain.com相同
And all other subdomains.
和所有其他子域名。
I want sessions and cookies to hold!
我希望会话和cookie能够召开!
1 个解决方案
#1
12
Has nothing to do with Express. It's the settings on the cookie itself that matter. Set its domain to .mydomain.com
and you should be fine.
与Express无关。它本身就是cookie本身的设置。将其域名设置为.mydomain.com,您应该没问题。
EDIT: The OP wanted more details, so here are the examples from the code.
编辑:OP想要更多细节,所以这里是代码中的例子。
connect.createServer( connect.cookieParser() , connect.session({ cookie: { domain : ".mydomain.com" }}) );
and
和
res.cookie('remember', 1, { domain : ".mydomain.com" });
should work.
应该管用。
#1
12
Has nothing to do with Express. It's the settings on the cookie itself that matter. Set its domain to .mydomain.com
and you should be fine.
与Express无关。它本身就是cookie本身的设置。将其域名设置为.mydomain.com,您应该没问题。
EDIT: The OP wanted more details, so here are the examples from the code.
编辑:OP想要更多细节,所以这里是代码中的例子。
connect.createServer( connect.cookieParser() , connect.session({ cookie: { domain : ".mydomain.com" }}) );
and
和
res.cookie('remember', 1, { domain : ".mydomain.com" });
should work.
应该管用。