为什么小弟我的网页会很慢
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 Article
How Long Does It Take To Beat Split Fiction?
3 weeks ago
By DDD
Repo: How To Revive Teammates
3 weeks ago
By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
3 weeks ago
By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
1 weeks ago
By 尊渡假赌尊渡假赌尊渡假赌

Hot tools Tags

Hot Article
How Long Does It Take To Beat Split Fiction?
3 weeks ago
By DDD
Repo: How To Revive Teammates
3 weeks ago
By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
3 weeks ago
By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
1 weeks ago
By 尊渡假赌尊渡假赌尊渡假赌

Hot Article Tags

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

How to solve the problem that SpringBoot cannot scan the Controller

How to add URL prefix to SpringBoot multiple controllers

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

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

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

The usage and function of Vue.use function
