Home > Backend Development > PHP Tutorial > 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

墨辰丷
Release: 2023-03-28 10:42:01
Original
3623 people have browsed it

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;));
    }*/
  }
}
?>
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template