This page has generated too many redirects. Clearing cookies on this website or allowing third-party cookies may resolve this issue.

Source: Internet
Author: User
Keywords Php
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:

    1. Detects if the session exists, and the session has direct access

    2. 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.

    3. 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:

    1. Detects if the session exists, and the session has direct access

    2. 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.

    3. 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.

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.