Home Backend Development PHP Tutorial 为什么小弟我的网页会很慢

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

Jun 13, 2016 pm 01:12 PM
controller function login

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

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-&gt;_init_user();
        
    }
    //初始化用户
    private function _init_user()
    {
        if(!empty($_SESSION['name']))
        {
            redirect('management');
        }
        else
        {
            redirect('login');
        }
    }
Copy after login


PHP code
<!--

Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/

-->class Management extends Admin_Controller {

    public function index()
    {
        $this-&gt;load-&gt;view('management');
    }
Copy after login


PHP code
<!--

Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/

-->class Login extends Admin_Controller {

    public function index()
    {
        $this-&gt;load-&gt;view('login');
    }
    
    public function logins()
    {
        if($_POST['name'] == "admin" &amp;&amp; $_POST['passwd'] == "123456")
        {
            $_SESSION['name'] = $_POST['name'];
            redirect('management');
        }
        else
        {
            redirect('login');
        }
    }
}
Copy after login


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

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

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

Hot Article Tags

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to solve the problem that SpringBoot cannot scan the Controller How to solve the problem that SpringBoot cannot scan the Controller May 14, 2023 am 08:10 AM

How to solve the problem that SpringBoot cannot scan the Controller

What does function mean? What does function mean? Aug 04, 2023 am 10:33 AM

What does function mean?

How to add URL prefix to SpringBoot multiple controllers How to add URL prefix to SpringBoot multiple controllers May 12, 2023 pm 06:37 PM

How to add URL prefix to SpringBoot multiple controllers

How to use Flask-Login to implement user login and session management How to use Flask-Login to implement user login and session management Aug 02, 2023 pm 05:57 PM

How to use Flask-Login to implement user login and session management

What is the purpose of the 'enumerate()' function in Python? What is the purpose of the 'enumerate()' function in Python? Sep 01, 2023 am 11:29 AM

What is the purpose of the 'enumerate()' function in Python?

Detailed explanation of the role and function of the MySQL.proc table Detailed explanation of the role and function of the MySQL.proc table Mar 16, 2024 am 09:03 AM

Detailed explanation of the role and function of the MySQL.proc table

The usage and function of Vue.use function The usage and function of Vue.use function Jul 24, 2023 pm 06:09 PM

The usage and function of Vue.use function

What is the usage of js function What is the usage of js function Oct 07, 2023 am 11:25 AM

What is the usage of js function

See all articles