1. 程式人生 > >js localStorage儲存/獲取/刪除

js localStorage儲存/獲取/刪除

var TOKEN_KEY = "jwtToken";

//取值

 function getJwtToken() {
        return localStorage.getItem(TOKEN_KEY);
    }

//儲存
    function setJwtToken(token) {
        localStorage.setItem(TOKEN_KEY, token);
    }

//刪除
    function removeJwtToken() {
        localStorage.removeItem(TOKEN_KEY);
    }