メインドメインとすべてのサブドメインの間でセッションCookieを共有する必要があります。私はexpressjsフレームワークに基づいて2つのnodejsサービスがあります。利用可能なサブドメインCookieにアプリケーションを設定するにはどうすればよいですか?
// example.local
...
app.use(session({
cookie: {
domain: "example.local"
}
, key: 'sid'
, secret: '[my secret]'
, saveUninitialized: true
, resave: true
, store: new RedisStore({
host: 'localhost',
port: 6379
})
}));
// blog.example.local
...
app.use(session({
// what should I write here? <---------
}));
は、だから私の質問は、私はexample.local
の既存のクッキーへのアクセスを得るためにblog.example.local
のセッション構成で書くべき何ですか?
EDIT:@yeinielが示唆するよう、私は次のようにblog.example.local
に同じ設定を使用する必要があります。
// blog.example.local
...
app.use(session({
cookie: {
domain: "example.local"
}
, key: 'sid'
, secret: '[my secret]'
, saveUninitialized: true
, resave: true
, store: new RedisStore({
host: 'localhost',
port: 6379
})
}));
は、それは十分ですか私はそれを最適化することができますか?
だから私は 'example.local'の設定を' blog.example.local'にコピーして貼り付けする必要がありますか? – Erik
はい、それだけです。 – yeiniel