5

i've a node app that use a session stored into a cookie. That app are invoked fron different domain, so i need to store the cookie with the right domain.

I followed this solution

It works but i have a little problem.

I start the app and open my browser the app work fine, the cookie are stored rightly. Well if restart the app (forever restart) and reload the windows in the browser the app doesn't work, the session are not recognize, but i see the cookie stored as resource in my browser. If delete the cookie and reload my window the app work fine, the session works rightly and so the app and i see the cookie on my resource.

it works rightly or not?

Any help are appreciated

Community
  • 1
  • 1
Zauker
  • 2,344
  • 3
  • 27
  • 36
  • It works. But `mwCache` is in nodejs memory, not in mongo. So you'll need to store it in mongo rather than in memory otherwise cookies will get destroyed with your `node` process an when your app will be in production mode, the memory might get too bloody full with thousands of users logged in :/ – Vinz243 Sep 23 '14 at 14:27
  • @Vinz243 Right `mwCache` is in memory, but it store an item per domain, isn't? If my app use 4 domains `mwCache` will have 4 items, so i don't understand the memory problem with thousands user logged in. I don't understand the reason why i need destroy cookie by hand (if browser is open and cookie stored) if restart my app, the new restarted app isn't able to overwrite the old cookie and update it? – Zauker Sep 24 '14 at 06:12
  • Because mwCache get destroyed, isn't it?* – Vinz243 Sep 24 '14 at 10:22
  • 1
    @Zauker hey, I would like to use express session for two different tld: x.com and x.net have you found a good solution yet? – karlkurzer Jun 12 '16 at 16:56
  • @karlkurzer now I'm using Express 4.x. With Express 4.0 I use express-session module to handle the session and connect-redis for store the session data. With this solution I haven't error/problem so I don't need hack too. Do you have some issues with your express? – Zauker Jun 13 '16 at 12:58
  • @Zauker I am also using express 4.x, but what I want to achieve, is that a cookie that gets set on _x.net_ is also valid on _x.com_ so that users can use either of my top level domains and don't need to log in twice – karlkurzer Jun 14 '16 at 17:08

0 Answers0