It's Normal for website login, to have a choice of "remember me", in that case user should not need to input credentials next time, until the cookies expired.
Today, the expires can be set in nuxt.config.js->auth->cookie->options.
But it's very hard to programatically change it in Vue component, login page for example.
There is API of this.$auth.$storage.setCookie(key, val, isJson), but only change cookies related value, and can not change globally the expires value, so it will not be valid eventually.
There are another API: this.$auth.$storage.setUniversal() but the expires options can not be passed in currently.
I'm not sure if this is a bug or I made some mistake, but it's essential to enable this feature.
Enable programatically change the cookie expires value globally, in Vue component
Has there been any progress on this feature, or a way to get similar behavior?
It's been more than a year and no one still adds this feature?
You're welcome to implement it @rancou ;)
You're welcome to implement it @rancou ;)
Would be great. Don't think im qualified, though. I'm still fairly a beginner.
Hey guys! I can work on this feature ;)
@JoaoPedroAS51 Any news?)
Actually setCookie method accepts options object https://github.com/nuxt-community/auth-module/blob/3f0073bc341c1bd19c3da1db6034f42e9414dfb7/src/core/storage.ts#L231 have you tried it yet? does not it work?
@gerardolopezduenas not super familiar with this stuff, how would/should I make nuxt-auth-module setCookie with this option?
you can do something like this:
this.$auth.$storage.setCookie('cookieName', 'cookieValue', { expires: 5 //this should be days }
you can confirm it works in the browser

thanks for the example, really appreciate it @gerardolopezduenas
Today i made this feature and this is my trick. (Using new codes in my below comment)

@dukinfotech Why don't you post it as code?
For anyone who like my approach way. By default, cookies expire date will be reset when refresh the window (Press F5). So, you need set them again in layout component. And this is my new codes.
(I'm using this package for cookie management)
File login.vue
// this.cookieExpire = 14 (cookie will expire after 2 weeks)
if (this.isRememberMe) {
let now = new Date();
now.setDate(now.getDate() + this.cookieExpire)
this.$cookies.set('auth_expire', now, 60*60*24 * this.cookieExpire)
}
File remember-me.js (folder mixins)
export default {
mounted() {
let authExpire = this.$cookies.get('auth_expire');
if (authExpire) {
let authRefreshTokenLocal = this.$cookies.get('auth._refresh_token.local')
let authTokenLocal = this.$cookies.get('auth._token.local')
let authStrategy = this.$cookies.get('auth.strategy')
this.$cookies.set('auth._refresh_token.local', authRefreshTokenLocal, authExpire)
this.$cookies.set('auth._token.local', authTokenLocal, authExpire)
this.$cookies.set('auth.strategy', authStrategy, authExpire)
}
}
}
And finally, import remember-me mixin to default layout (and others if you are using multi-layout).
Enjoy !!!
@dukinfotech Expiration / Max-age of cookies was changed but still comes back to default value (session).

Most helpful comment
Today i made this feature and this is my trick. (Using new codes in my below comment)
