A, problem,

1.1 environment Computer environment: Windows 10; Development tools: IntelliJ IDEA; Database environment: Redis 3.2.100 JDK environment: Jdk1.8

1.2. Question [Vue] When we exit another system, how can we do it cleanly?

Second, the answer

SessionStorage does not cache tokens and other token information of users. 2. LocalStorage does not have sensitive information of the system. 3. No user information is cached in cookies; 4. If it is a single project, the content page in the current page cannot be displayed; 5. The login page or prompt page is displayed.

Let’s explain one by one:1, the sessionStorageIf the user’s token is inserted into the browser during login and the user’s information is equivalent to that of the user, the user’s token should be deleted from the browser upon exit. For details, please refer to [Window sessionStorage property】

sessionStorage.removeItem("token");
Copy the code

2, localStorage This usage is consistent with sessionStorage. For the difference between the two, please refer to: [LocalStorage and sessionStorage】

3, Cookies

Method 1: common method (attempt failed) Cookie, sometimes also used in the plural form of Cookies. The type is small text file. It is the data (usually encrypted) stored on the user’s local terminal by some websites for identifying the user’s identity and Session tracking, and temporarily or permanently stored by the user’s client computer. For the definition of Cookies, you can see [Baidu Encyclopedia -Cookies], or refer to this blogger’s blog

Cookies.remove("token");
Copy the code

②, Method 2: through the native JS method (try successfully)

/** * Get cookies */
    getCookie(name) {
      var arr,
        reg = new RegExp("(^| )" + name + "= (/ ^; (*). | $)");
      if ((arr = document.cookie.match(reg))) {
        return arr[2];
      } else {
        return false; }},/** * Delete cookies */
    delCookie(name) {
      var exp = new Date();
      exp.setTime(exp.getTime() - 1);
      var cval = this.getCookie(name);
      if (cval) {
        document.cookie = name + "=" + cval + "; expires="+ exp.toGMTString(); }},Copy the code

The Cookies can then be retrieved and deleted by calling these two JS methods;

4. If it is a single project, the content page in the current page cannot be displayed; Look at the organizational structure of your own project. Be sure to empty the current page container;

5. Go to the home page or login page.

End ~

Third, summary

Undertake project development (e-commerce, finance, live broadcasting and other Internet development projects), undertake outsourcing and other Internet business ~

References:

1, www.runoob.com/jsref/prop-…

2, www.runoob.com/jsref/prop-…

3, www.cnblogs.com/leijee/p/75…

4, baike.baidu.com/item/cookie…

5, blog.csdn.net/playboyanta…

Welcome to mine

CSDN blog: blog.csdn.net/River_Conti…

Wechat official account: Muqiao Community

Zhihu: zhang makino, www.zhihu.com/people/zhan…

Jane: www.jianshu.com/u/02c0096cb…