これは、Connect のセッション ミドルウェアの現在の実装では実行できませんが、セッション ミドルウェアをフォークして、セッション ID の生成方法、つまり次の行を変更できます。
https://github.com/senchalabs/connect/blob/master/lib/middleware/session.js#L202
「フォーク」とは、上記のファイルをコピーし、セッション ID の割り当てを変更し、セッション ミドルウェアを構成するときに代わりに新しいファイルを使用することを意味します。
アップデート:
カスタムIDでセッションを再生成する方法は次のとおりです(注-これは単なるアイデアであり、テストしていません):
// this is the function you'll be calling in your routes or whatever
req.regenerateSession = function(newSid) {
// keep old session data
var oldSessionData = req.session;
// destroy current session and make a new one with your custom id
store.destroy(req.sessionID, function() {
store.generate(req, newSid);
// copy back the session data
// since you don't want to lose it probably
req.session = oldSessionData;
});
}
// replace the session store generate function to accept a custom sessionID
// https://github.com/senchalabs/connect/blob/master/lib/middleware/session.js#L201
store.generate = function(req, customID) {
req.sessionID = customID || utils.uid(24);
req.session = new Session(req);
req.session.cookie = new Cookie(req, cookie);
}