简体   繁体   English

使用www和非www网址进行快速会话

[英]Express Session with www and non-www url

I currently resolve mySite.com and www.mySite.com to the same server. 我目前将mySite.com和www.mySite.com解析到同一服务器。 What path setting do I use in the session options to ensure I'm only creating a single session that can be "shared" between those two urls? 我在会话选项中使用什么路径设置来确保仅创建一个可以在这两个URL之间“共享”的单个会话?

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

You can set the domain parameter in cookie with a leading . 您可以在cookie使用前导设置domain参数. to allow the cookie for all subdomains (including www): 允许所有子域(包括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
} ) )

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM