Home > Article > Backend Development > PHP automatically jumps to the login page if you are not logged in
In order to satisfy the user experience, users need to log in to jump to the page. This article will share with you the example code of PHP that automatically jumps to the login page without logging in. Friends who need it can refer to the specific code
As shown below:
<?php namespace Home\Controller; use Think\Controller; class BaseController extends Controller{ //基础信息,判断登陆 public function __construct(){ parent::__construct(); /*if(!session('?user')){ redirect(U('Home/Login/index')); }*/ } } ?>
The above is the entire content of this article, I hope it will be helpful to everyone's study.
Related recommendations:
PHP Automatic jump to a certain page
PHP reports an error and automatically jumps
The above is the detailed content of PHP automatically jumps to the login page if you are not logged in. For more information, please follow other related articles on the PHP Chinese website!