Skip to content

Commit a108ff7

Browse files
committed
Fix bug with session expiration
1 parent 4c41b11 commit a108ff7

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

utils/apollo/ApolloClient.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,10 @@ export const middleware = new ApolloLink((operation, forward) => {
2626
const sessionAge = process.browser
2727
? localStorage.getItem('woo-session-expiry')
2828
: null;
29-
29+
const todaysDate = new Date();
3030
const oneDay = 60 * 60 * 24 * 1000;
31-
const olderThan24h = new Date() - sessionAge > oneDay;
31+
const olderThan24h = new Date(todaysDate) - new Date(sessionAge) > oneDay;
32+
3233
if (olderThan24h && process.browser) {
3334
localStorage.removeItem('woo-session');
3435
localStorage.removeItem('woo-session-expiry');

0 commit comments

Comments
 (0)