How to make my session the last cross subdomain in Node.js Express?

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

And all the other subdomains.

I want sessions and cookies saved!

+8
javascript express
source share
1 answer

It has nothing to do with Express. It matters the setting of the cookie itself. Set your .mydomain.com domain and everything will be fine.

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

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

and

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

must work.

+12
source share

All Articles