Welcome Guest, Not a member yet? Register   Sign In
How I can to filter browsers using CI 2.2?
#1

(This post was last modified: 05-20-2015, 05:14 AM by gloton.)

Sorry, I do not speak English, but I have a question.
How I can to redirect or show other view when the people enter to my website using Internet Explorer with a version less than 9 ?.

I try whit the follow code:

Controller file:inicio.php
PHP Code:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class 
Inicio extends CI_Controller {

 public function 
__construct()
 {
 
parent::__construct();
 
$this->load->library('user_agent');
 }
 public function 
index()
 {
 
 if(
true)
 {
 
$data["browser"] = $this->agent->browser();
 
$data["version"] = $this->agent->version();
 
$this->load->view("paginacion_view.php",$data);
 
//redirect('some_page');
 
}


 }



View:paginacion_view.php
PHP Code:
<?php
echo "hola mundo";
echo 
"<br />";
echo 
$browser;
echo 
"<br />";
echo 
$version;
exit(); 

The output is (for internet explorer 7, 8 or 9), so there is not difference

hola mundo
Mozilla
5.0
Reply
#2

Did you modify your /application/config/user_agents.php file? This could happen if the Mozilla entry in the $browsers array is placed before the entry for Internet Explorer (and the same goes with most/all of the entries before it by default).

If not, how are you testing this? I know many people will use browser plug-ins and other methods for testing IE compatibility on their websites, but some of those methods are better than others at emulating the browser in question, especially in the information they send to the server. When I can, I prefer to use virtual machines, like those supplied by Modern IE, to test the actual browser in question.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB