I wanna detect when a user clears his cookies or session storage. Can JavaScript detect such event? I wanna detect which user clears the cookies
Asked
Active
Viewed 24 times
2
-
I don't know some event or API for this, but I think you can try to inject code which will check the cookies or SessionStorage at intervals – Kirill May 20 '23 at 17:45
-
@Kirill thank you very much for suggesting a way. But I think that might slow down the code. And I can't get exact time the user cleared the cookies. Is there any other way? Please tell me if there is any. It will be more helpful to me. Thank You. – Mohamed Anas May 21 '23 at 05:30
-
Today i found similar ask https://stackoverflow.com/questions/14344319/can-i-be-notified-of-cookie-changes-in-client-side-javascript Most popular answer is about interval polling. I think there no another way – Kirill May 21 '23 at 09:15
-
Also you should visit https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/cookies/onChanged You can solve problem with cookies in firefox – Kirill May 21 '23 at 09:17