redux-persist-cookie-storage icon indicating copy to clipboard operation
redux-persist-cookie-storage copied to clipboard

Expiration time doesn't work for store key.

Open krzywiecki opened this issue 6 years ago • 1 comments

I have in my cookies/store such object:

auth: {
    accessToken: 'myToken',
    refreshToken: 'myRefreshToken',
}

And I want accessToken to expire from cookies/store after 30 seconds (later on it will be 1h). I'm trying to do it like that:

const authPersistConfig = {
    key: 'auth',
    storage: new CookieStorage(Cookies, {
        expiration: {
            'default': null,
            'accessToken': 30,
        }
    }),
};

but the accessToken still exist in cookie after this time. Am I doing something wrong?

krzywiecki avatar Oct 11 '18 15:10 krzywiecki

storeKey always update expiration when user refresh browser. so not const if set expiration. like in src code always set in default

[update] answer i have found where storeKey not set in expires u must give configuration like this. i using redux-persist v5.10.1

const rootPersistConfig = {
  key: 'root',
  storage: new CookieStorage(Cookies, {
    expiration: {
      'persist:root': 120
    }
  })
};

zanisis avatar Jan 30 '19 11:01 zanisis