title: How to clear Redux Persist Store after a certain time
body: <p>In my React App, I want the user's cart and data to be cleared after a certain time.</p>
  <p>I tried using a setTimeout() function that runs persistor.purge() after 1 hour, but this method doesn't work when you close the browser tab. So if the user, opens again the website after days, the store data is remained there.</p>
  <p>Second method, I tried (redux-persist-expire) package, but nothing changes in the website.
  My code, index.js file,</p>
  <pre><code>import { persistStore, persistReducer } from &quot;redux-persist&quot;;
  import storage from &quot;redux-persist/lib/storage&quot;;
  import { createStore, compose, applyMiddleware } from &quot;redux&quot;;
  import thunk from &quot;redux-thunk&quot;;
  
  const composeEnhancers = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose;
  const expireReducer = require(&quot;redux-persist-expire&quot;);
  
  const persistConfig = {
      key: &quot;root&quot;,
      storage: storage,
      transforms: [expireReducer(rootReducer, { expireSeconds: 10 })],
  };
  
  const pReducer = persistReducer(persistConfig, rootReducer);
  const store = createStore(pReducer, composeEnhancers(applyMiddleware(thunk)));
  
  export const persistor = persistStore(store);
  export default store;
  </code></pre>
  <p>Is there something needed to be fixed in the code? Or is there a better way to approach it.</p>