Clearing localStorage with setTimeout ()?
The cart is stored in localStorage. According to tz, the data must be kept for a month.
It is not entirely clear how setTimeout will approach this problem. You don't expect the user to leave the tab this month, do you?
In my opinion, it is more expedient to store the creation date of the cart in localStorage. Then, using a script, check whether 30 days have passed since the basket was created. If so, empty the trash.Anonymous
by tz, the data must be kept for a month.
Users can clear ls themselves whenever they want.
Not critical if cleaned with setTimeout ()?
This is critical, as setTimeout () will work while the user is on the page and your timer may not fire at the right time.Anonymous
To place the code, please use CodePen or similar tool. Thanks you!