Web tip:
This page has generated too many redirects. Clearing cookies on this website or allowing third-party cookies may resolve this issue. If this cannot be resolved, there may be a problem with the server configuration, not your computer.
A website, divided into the front desk and the background, all need their own account password login.
In order to save the login status, I put the login information in the cookie, set the cookie expiration time is unlimited, if the session expires, remove the login information from the cookie to verify the login.
Front desk does not have any problems, can be automatically logged in, the background in the closed browser session after the failure to enter, prompted: This page generated too many redirects. Clearing cookies on this website or allowing third-party cookies may resolve this issue. If this cannot be resolved, there may be a problem with the server configuration, not your computer.
The code behind the front is basically the same:
Detects if the session exists, and the session has direct access
Session does not exist, detects cookies, and obtains login information via cookies. The information is entered correctly and the information error jumps to the login screen.
Neither session nor cookie exists and jumps to the login screen.
//验证是否登录 public function _initialize(){ $session=session('uid'); $cookie=cookie('auto'); //session失效 cookie失效 if(!isset($session) AND !isset($cookie)){ $this->redirect('Login/login',array(),1,'请先登录'); exit; } //session失效 cookie有效 if(!isset($session) AND isset($cookie)){ //使用cookie登录 $AdminModel=D('Admin/Admin'); $result=$AdminModel->login($cookie); if($result>0){//登录成功 //判断管理员身份 if($result==1){//超级管理员 $this->redirect("Task/task1"); exit; }elseif($result>1){//普通管理员 $this->redirect("Eat/displayEat"); exit; } } else {//登录失败 cookie中的信息不可用 $this->redirect('Login/login',array(),1,'登录信息已改变,请重新登录'); exit; } }
Reply content:
Web page Tip: This page has generated too many redirects. Clearing cookies on this website or allowing third-party cookies may resolve this issue. If this cannot be resolved, there may be a problem with the server configuration, not your computer.
A website, divided into the front desk and the background, all need their own account password login.
In order to save the login status, I put the login information in the cookie, set the cookie expiration time is unlimited, if the session expires, remove the login information from the cookie to verify the login.
Front desk does not have any problems, can be automatically logged in, the background in the closed browser session after the failure to enter, prompted: This page generated too many redirects. Clearing cookies on this website or allowing third-party cookies may resolve this issue. If this cannot be resolved, there may be a problem with the server configuration, not your computer.
The code behind the front is basically the same:
Detects if the session exists, and the session has direct access
Session does not exist, detects cookies, and obtains login information via cookies. The information is entered correctly and the information error jumps to the login screen.
Neither session nor cookie exists and jumps to the login screen.
//Verify the login public function _initialize () {$session =session (' uid '); $cookie =cookie (' Auto '); Session Expiration Cookie fails if (!isset ($session) and!isset ($cookie)) {$this->redirect (' Login/login ', Array (), 1, ' Please login first '); Exit }//session Invalid cookie valid if (!isset ($session) and Isset ($cookie)) {//Use cookies to log in $AdminMod El=d (' admin/admin '); $result = $AdminModel->login ($cookie); if ($result >0) {//Login successful//Determine administrator status if ($result ==1) {//Super Administrator $this->redire CT ("Task/task1"); Exit }elseif ($result >1) {//General manager $this->redirect ("Eat/displayeat"); Exit }} else {//The information in the failed login cookie is not available $this->redirect (' Login/login ', Array (), 1, ' Login information changed, please log in again '); Exit } }
Don't know if your Login/login
method has been inherited _initialize()
? If you inherit, you must redirect to a dead loop!
Redirect issue, clear the website cookie.