Home  >  Article  >  Backend Development  >  为什么小弟我的网页会很慢

为什么小弟我的网页会很慢

WBOY
WBOYOriginal
2016-06-13 10:47:57936browse

为什么我的网页会很慢?
先看代码吧

PHP code
<!--Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->class Admin_Controller extends CI_Controller {    public function __construct()    {        parent::__construct();    $this->_init_user();            }    //初始化用户    private function _init_user()    {        if(!empty($_SESSION['name']))        {            redirect('management');        }        else        {            redirect('login');        }    }


PHP code
<!--Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->class Management extends Admin_Controller {    public function index()    {        $this->load->view('management');    }


PHP code
<!--Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->class Login extends Admin_Controller {    public function index()    {        $this->load->view('login');    }        public function logins()    {        if($_POST['name'] == "admin" && $_POST['passwd'] == "123456")        {            $_SESSION['name'] = $_POST['name'];            redirect('management');        }        else        {            redirect('login');        }    }}


现在的问题来了,当我在最顶层的构造函数里加上$this->_init_user();之后,网页无论是刷新还是登陆都很慢。这是为什么?

------解决方案--------------------
还不会。
------解决方案--------------------
session_start() 开启了吗? 最好加个isset($_SESSION['name'])
个人愚见
------解决方案--------------------
YSlow 浏览器插件,分析网页,很详细
------解决方案--------------------
很简单,你的网页循环重定向了

当已经登录了,访问management的时候,_init_user又把你重定向到management
当还没登录,访问login的时候,又重定向到login
如此往复
------解决方案--------------------
顺序问题。
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