Visit the Site page, some pages need authorization to access, this time will require users to login, jump to the login page login.php, how to achieve the login back to the page just visited
Project requirements to visit the site page, some pages need authorization to access, this time will require users to login, jump to the login page login.php, how to achieve the login back to the page just visited. Solution 1: Before jumping to the login page to save the current access page URL to the cookie inside, login authentication authorization passed, remove the URL value from the cookie, jump to the URL specified by the page. The implementation of my current program is based on the thinkphp framework, we will have a parent class controller, I will add this cookie code to the baseaction inside the _initialize () function, so that the program greatly simplifies the workload. The code is as follows: $refer = ' http://'. $_server [' Http_host ']. $_server[' Request_uri ']; Cookie::set (' refer ', $refer); Login detection function Inside we add: The code is as follows: $refer = Cookie::get (' refer '); Now this $refer is our previous visit to the page, we can return this parameter through Ajax, and then jump, or directly using the program to jump, depending on the needs of your program. Solution 2: In addition to the form of stored as cookies, I believe you have seen many large Web sites directly using Get form, Drupal's landing mechanism is this. The idea is this: before jumping to the login page, you pass the URL of the page visited by the visitor as a parameter, and after the login is authenticated, the user is granted access to the page specified by the URL. For example, before the login URL is: openphp.html When visitors visit, click No permissions, jump to the address of the login page is login.php?url=openphp.html, so that when you log in, you can get this parameter Openphp.html, login verification successful jump to openphp.html this page is OK. In general I also on these two ideas, if you have a better idea, sincerely hope you can tell me.