如何刪除網路儲存?
在本地機器上儲存敏感資料很危險,可能會留下安全漏洞。會話儲存資料會在會話終止後立即被瀏覽器刪除。
要清除本地儲存設定,你需要呼叫 localStorage.remove(‘key’),其中‘key’是你要刪除的值的鍵。如果你要清除所有設定,則需呼叫 localStorage.clear() 方法。
<!DOCTYPE HTML>
<html>
<body>
<script>
localStorage.clear();
// Reset number of hits.
if( localStorage.hits ){
localStorage.hits = Number(localStorage.hits) +1;
} else{
localStorage.hits = 1;
}
document.write("Total Hits :" + localStorage.hits );
</script>
<p>Refreshing the page would not to increase hit counter.</p>
<p>Close the window and open it again and check the result.</p>
</body>
</html>
廣告
資料結構
網路
RDBMS
作業系統
Java
iOS
HTML
CSS
Android
Python
C 程式設計
C++
C#
MongoDB
MySQL
Javascript
PHP