开发者

How do I make my sessions last cross-subdomain in Node.js Express?

开发者 https://www.devze.com 2023-03-28 21:23 出处:网络
I want http://mydomain.com to be the same as http://www.mydomain.com 开发者_运维百科And all other subdomains.

I want http://mydomain.com to be the same as http://www.mydomain.com

开发者_运维百科And all other subdomains.

I want sessions and cookies to hold!


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.

EDIT: The OP wanted more details, so here are the examples from the code.

  connect.createServer(
      connect.cookieParser()
    , connect.session({ cookie: { domain : ".mydomain.com" }})
  );

and

 res.cookie('remember', 1, { domain : ".mydomain.com" });

should work.

0

精彩评论

暂无评论...
验证码 换一张
取 消