0

I have two Node.js web applications. One is an Express application, the other is a Restify Application.

Can I use this cookie-sessions module: https://github.com/expressjs/cookie-session in both applications, so that if a user logs into one of the applications, they will also be logged in to the other application?

Please let me know if this is possible, and if so, tips on implementation would be greatly appreciated.

ac360
  • 7,735
  • 13
  • 52
  • 91

1 Answers1

1

Cookies are stored in the browser and are sent to the specific server that they correspond to with every request made to that server. Cookies from one server are never sent to another server. When a cookie is created, it is configured to either be sent with all path requests on the server or only one specific path on the server.

If your two applications are on the same server and the cookies in question are set for unrestricted path access (which a session-based cookie normally would be), then the the two applications will see exactly the same cookies. If they are on different servers, then neither will see the cookies of the other and there is nothing you can do server-side to cause the browser to send you cookies that belong to a different domain.

jfriend00
  • 683,504
  • 96
  • 985
  • 979