: This article mainly introduces how php defines filters like JavaWeb. For more information about PHP tutorials, see. Php verifies user login in a unified manner to prevent user input links from entering some website interfaces in the unlogged status
We know that the filters in php only filter data input. they do not intercept certain url filters like the Java Servlet technology, so that before the requests come, and before sending them, requests and outputs can be processed freely and transparently, and can be forwarded at the same time. the function is quite powerful. most Java filters recognize filters through the examples of character encoding filtering, then, a large number of filters are used in the actual project, which is very powerful. at the same time, the Java MVC framework uses filters for forwarding and defines various processing methods, but php does not seem to have any, I am using the ThinkPhp framework, but this framework is not provided, but I think this problem is not difficult, so I wonder if there is a setting, or in some places, any request passes through it. I want to find it in the thinkphp framework, but it is time-consuming and there are other projects that do not have time. So I came up with a solution on the Internet,
In the PHP configuration file php. in the INI file, auto_prepend_file = "a file" is set to add this file before each php file. it is usually a php file and I add a filter. php: Put this file in php. filter. the content of php is
$ Url = $ _ SERVER ["PHP_SELF"]; $ url = substr ($ url, strlen ($ url)-8, 2); // echo $ url; if ($ _ SERVER ["PHP_SELF"] = '/miaomi/index. php/Index/login ') | ($ _ SERVER ["PHP_SELF"] ='/miaomi/index. php ') | $ url = 'in') {} else {SESSION_START (); if ((! Isset ($ _ SESSION ['username']) {echo"