Home  >  Article  >  Backend Development  >  PHP automatically jumps to the login page if you are not logged in

PHP automatically jumps to the login page if you are not logged in

墨辰丷
墨辰丷Original
2018-05-29 11:37:103590browse

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(&#39;?user&#39;)){
      redirect(U(&#39;Home/Login/index&#39;));
    }*/
  }
}
?>

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

After successful payment by scanning the QR code on PC via WeChatautomatically jumpsphp Version code sharing

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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn