使用www和非www url进行快速会话

时间:2015-01-20 15:39:42

标签: node.js session express

我目前将mySite.com和www.mySite.com解析为同一台服务器。我在会话选项中使用什么路径设置,以确保我只创建一个可以共享"这两个网址之间?

app.use ( session ( {
    store : new RedisStoreSession(),
    secret: 'keyboardCat',
    cookie: { maxAge: 3.156e+10 },
    path: '/'  //this is the default - i'm not setting anything yet
} ) )

1 个答案:

答案 0 :(得分:1)

您可以在domain中使用前导cookie设置.参数,以允许所有子域名(包括www)的Cookie:

app.use ( session ( {
  store : new RedisStoreSession(),
  secret: 'keyboardCat',
  cookie: { maxAge: 3.156e+10, domain: '.example.org' },
  path: '/'  //this is the default - i'm not setting anything yet
} ) )