title: Codeigniter - check if session and cookies enabled
body: <p>How do you control from hooks files if the session and the cookies are enabled on user browser?</p>
  
  <p>this is my code unfortunately it doesn't works:</p>
  
  <p>cookie.php (/hooks)
      class Cookie {</p>
  
  <pre><code>function control_cookies_enabled()
  {
   $CI =&amp; get_instance();
   $CI-&gt;session-&gt;unset_userdata('enabled_cookies',false);
   $CI-&gt;session-&gt;set_userdata('enabled_cookies','1');
  
   if($CI-&gt;session-&gt;userdata('enabled_cookies') !== '1'){
    redirect(site_url('home'));
   }
  }
  
  }
  </code></pre>
  
  <p>then i call that in /config/hooks.php</p>
  
  <pre><code> $hook['pre_controller'] = array(
                                  'class'    =&gt; 'cookie',
                                  'function' =&gt; 'control_cookies_enabled',
                                  'filename' =&gt; 'cookie.php',
                                  'filepath' =&gt; 'hooks'
  
                                  );
  </code></pre>
  
  <p>Thanks.</p>