Sessionstorage Front page Jump Management

Source: Internet
Author: User
Tags sessionstorage

A business scenario that corresponds to one scenario:

If the implementation does not have access to the view A, view B, view C page and jumps to the login view if the user is not logged in successfully

Add the following in the success branch of the Login.view login Ajax Request:

  

$.ajax ({
URL: "",
Type: "Get",
DataType: "JSON",
Success:function (res) {
Sessionstorage.setitem ("Isload", True) //If this is a page routing table, you can do the routing control display.
},
Error:function (res) {
Console.log (' res = ', res);
}
})

In the initialization rendering of other pages such as view a, add the following:

var isLoaded = Sessionstorage.getitem ("Isload");
if (!isloaded) {
Window.location = (".. /index.html "); Login Page
}

As a result, each time you log in to the session domain, if you are not logged in successfully (get certified). You do not have permission to access other pages.

Note: Sessionstorage is used because the sessionstorage is emptied after it is closed. Complies with security rules. Sessionstorage is equivalent to a global variable in a single page application (similar to rootscope in angular) that can be shared across all view. It is also possible to implement some mechanism of angular rootscope by Sessionstorage. Here just to do a check whether the login, interested friends can be based on the implementation of routing management.

Sessionstorage Front page Jump Management

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.