how to clear localstorage,sessionStorage and cookies in javascript? and then retrieve?

前端 未结 3 1531
旧时难觅i
旧时难觅i 2020-12-05 04:07

How to completely clear localstorage, sessionStorage and cookies in javascript ?

Is there any way one can get these values bac

3条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-05 04:34

    There is no way to retrieve localStorage, sessionStorage or cookie values via javascript in the browser after they've been deleted via javascript.

    If what you're really asking is if there is some other way (from outside the browser) to recover that data, that's a different question and the answer will entirely depend upon the specific browser and how it implements the storage of each of those types of data.

    For example, Firefox stores cookies as individual files. When a cookie is deleted, its file is deleted. That means that the cookie can no longer be accessed via the browser. But, we know that from outside the browser, using system tools, the contents of deleted files can sometimes be retrieved.

    If you wanted to look into this further, you'd have to discover how each browser stores each data type on each platform of interest and then explore if that type of storage has any recovery strategy.

提交回复
热议问题