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->_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->load->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->load->view('login');
    }
    
    public function logins()
    {
        if($_POST['name'] == "admin" && $_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 AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

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

When a SpringBoot novice creates a project, the Controller cannot be scanned for a series of problems 1.2.3.4.5.6. Another way is to add @ComponentScan(basePackages={"xxx.xxx.xx","xxx.xxx" when starting the service class) .xx”}) is the fully qualified name of the package, which can be used for multiple SpringBoot custom controllers. The SpringBoot custom controller route cannot be scanned and cannot be found because the startup class and the custom Controller package are not in the same directory. Officially recommended placement of application.java

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

Function means function. It is a reusable code block with specific functions. It is one of the basic components of a program. It can accept input parameters, perform specific operations, and return results. Its purpose is to encapsulate a reusable block of code. code to improve code reusability and maintainability.

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

Preface In some cases, the prefixes in the service controller are consistent. For example, the prefix of all URLs is /context-path/api/v1, and a unified prefix needs to be added to some URLs. The conceivable solution is to modify the context-path of the service and add api/v1 to the context-path. Modifying the global prefix can solve the above problem, but there are disadvantages. If the URL has multiple prefixes, for example, some URLs require prefixes. If it is api/v2, it cannot be distinguished. If you do not want to add api/v1 to some static resources in the service, it cannot be distinguished. The following uses custom annotations to uniformly add certain URL prefixes. one,

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 Introduction: Flask-Login is a user authentication plug-in for the Flask framework, through which we can easily implement user login and session management functions. This article will introduce how to use Flask-Login for user login and session management, and provide corresponding code examples. 1. Preparation Before using Flask-Login, we need to install it in the Flask project. You can use pip with the following command

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

In this article, we will learn about enumerate() function and the purpose of “enumerate()” function in Python. What is the enumerate() function? Python's enumerate() function accepts a data collection as a parameter and returns an enumeration object. Enumeration objects are returned as key-value pairs. The key is the index corresponding to each item, and the value is the items. Syntax enumerate(iterable,start) Parameters iterable - The passed in data collection can be returned as an enumeration object, called iterablestart - As the name suggests, the starting index of the enumeration object is defined by start. if we ignore

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. MySQL is a popular relational database management system. When developers use MySQL, they often involve the creation and management of stored procedures (StoredProcedure). The MySQL.proc table is a very important system table. It stores information related to all stored procedures in the database, including the name, definition, parameters, etc. of the stored procedures. In this article, we will explain in detail the role and functionality 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

Usage and Function of Vue.use Function Vue is a popular front-end framework that provides many useful features and functions. One of them is the Vue.use function, which allows us to use plugins in Vue applications. This article will introduce the usage and function of the Vue.use function and provide some code examples. The basic usage of the Vue.use function is very simple, just call it before Vue is instantiated, passing in the plugin you want to use as a parameter. Here is a simple example: //Introduce and use the plug-in

clearstatcache() function in PHP clearstatcache() function in PHP Sep 07, 2023 am 09:33 AM

The clearstatcache() function is used to clear the file status cache. PHP caches the information returned by the following functions −stat()lstat()file_exists()is_writable()is_readable()is_executable()is_file()is_dir()filegroup()fileowner()filesize()filetype()fileperms() What to do To provide better performance. Syntax voidclearstatecache() Parameter NA Return value clearstatcache(

See all articles