Restricting access to page unless coming from a specific page

后端 未结 5 1745
忘掉有多难
忘掉有多难 2021-01-22 12:27

I\'m trying to figure out how to restrict access to a page unless the page is navigated to from a specific \"gate\" page. Essentially I want the page to be unaccessible unless y

5条回答
  •  面向向阳花
    2021-01-22 13:11

    The only effective way is to set and check some access token at the server (it is trivial to manipulate any data at the client, therefore plain JS and HTML are not enough; same for the Referer header). A simplified example in PHP:

    gate_page.php:

    Protected area
    

    protected_page.php:

    entry page first.';
        exit();
    }
    
    // whatever happens to be at the protected page
    

    Of course, it is easy to add some password checking and/or other security elements, this is the bare minimum.

提交回复
热议问题