Apply for Zend Framework Certification Training

Codeigniter




Hooks in Codeigniter
               post_controller_constructor
Step -1
  Open up "application/config/config.php" and enable or set hooks to true.
  $config['enable_hooks'] = TRUE;

Step - 2
  Open up "application/config/hooks.php" and enter the following code into it. This will ensure 
that our hook is loaded.

 $hook['post_controller_constructor'][] = array(
                                'class'=>'Sslredirector',
                                'function' => 'redirectssl',
                                'filename' => 'Sslredirector.php',
                                'filepath' => 'hooks'
                                );

Step - 3
   Create class file  in  application/hooks/Sslredirector.php

class Sslredirector
{
  function redirectssl() 
  {
      $CI =& get_instance();
      $CI->config->config['base_url'] = str_replace('http://', 'https://', $CI->config->config['base_url']);
      if ($_SERVER['SERVER_PORT'] != 443) redirect($CI->uri->uri_string());
   
 }

}
                                    

< Session in codeigniter Last >



Ask a question



  • Question:
    {{questionlistdata.blog_question_description}}
    • Answer:
      {{answer.blog_answer_description  }}
    Replay to Question


Back to Top