Node.js Express Passport Cookie Expiration

前端 未结 2 1306
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-14 02:59

I am using Passport for authentication in my app, and I am also using Express. To summarize my issue: my login functionality works fine initially, but after any<

2条回答
  •  萌比男神i
    2020-12-14 03:35

    Set cookie name to value, where which may be a string or object converted to JSON. The path option defaults to "/".

    res.cookie('rememberme', '1', { expires: new Date(Date.now() + 900000), httpOnly: true });

    The maxAge option is a convenience option for setting "expires" relative to the current time in milliseconds. The following is equivalent to the previous example.

    res.cookie('rememberme', '1', { maxAge: 900000, httpOnly: true })

    Also the Link

    http://expressjs.com/api.html#res.cookie

提交回复
热议问题