Why is my webpage slow? Let's look at the code first. PHPcodeclassAdmin_ControllerextendsCI_Controller {publicfunction _ construct () {parent ::__ construct (); $ this-& gt; _ init_user (); why is my webpage slow?
Check the code first.
PHP code
Class Admin_Controller extends CI_Controller {public function _ construct () {parent ::__ construct (); $ this-> _ init_user ();} // initialize user private function _ init_user () {if (! Empty ($ _ SESSION ['name']) {redirect ('manager');} else {redirect ('login ');}}
PHP code
class Management extends Admin_Controller { public function index() { $this->load->view('management'); }
PHP code
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'); } }}
Now, the problem is that when I add $ this-> _ init_user () in the top-level constructor, the webpage is slow to refresh or log on. Why?
------ Solution --------------------
Not yet.
------ Solution --------------------
Is session_start () enabled? It is best to add an isset ($ _ SESSION ['name']).
Personal ignorance
------ Solution --------------------
YSlow browser plug-in, analyze the web page, very detailed
------ Solution --------------------
It's easy. your webpage is redirected cyclically.
When you have logged on to the management console, _ init_user redirects you to the management console.
When login is not logged on, it is redirected to login again.
So reciprocating
------ Solution --------------------
Sequence problems.