2015-02-23 107 views
0

我很努力地理解nodejs中的會話,我在同一個端口上有一個子域,但我必須再次登錄。允許nodejs會話繼承到子域

我想知道我怎麼配置的NodeJS共享同一個會議上,我使用passportjs登錄的用戶。

我一直在使用Redis的嘗試,但它不工作,我不明白。

app.use(session({ 
    secret: "something", 
    domain: '.app.localhost', 
    store : new RedisStore({ 
    host: '.app.localhost', 
    port : 9200 , 
    client: redisClient 
    }), 
    cookie : { 
    maxAge : 604800 // one week 
    } 
})); 

如何讓我的子域app.localhost與localhost共享相同的登錄會話?

+0

有沒有人有線索?你能爲我指出正確的方向嗎? – 2015-02-24 01:54:44

回答

0

假設您必須使用express-session包。如何安裝系統烹飪指的是一個域是這樣的。

app.use(session({ 
    secret: "something", 
    // domain: '.app.localhost', <-- This Don't put into the cookie 
    store : new RedisStore({ 
    host: '.app.localhost', 
    port : 9200 , 
    client: redisClient 
    }), 
    cookie : { 
    maxAge : 604800 // one week 
    domain: 'app.localhost', //<-- This put into the cookie the domain 
    } 
}));