Last updated on January 17, 2018
GET data is simply disallowed by CodeIgniter since the system utilizes URI segments rather than traditional URL query strings (unless you have the query string option enabled in your config file). The global GET array will be deleted by the Input class during system initialization to prevent Security Hacks.
To Enable GET Method in CodeIgniter, it is necessary to modify some configuration settings. The uri_protocol setting needs to be changed to PATH_INFO. See the Steps
if ( ! defined('BASEPATH')) exit('No direct script access allowed'); class Welcome extends CI_Controller { public function index() { //converts query string into global GET array variable parse_str($_SERVER['QUERY_STRING'],$_GET); //print $_GET array print_r($_GET); } } /* End of file welcome.php */ /* Location: ./application/controllers/welcome.php */
If you Point the browser with
http://localhost/index.php/welcome/?var1=1&var2=2&var3=3
Output will be something like this
class MY_Input extends CI_Input { function _sanitize_globals() { $this->allow_get_array = TRUE; parent::_sanitize_globals(); } }
It’s also necessary to modify some configuration settings. The uri_protocol setting needs to be changed to PATH_INFO and the ‘?’ the character needs to be added to the list of allowed characters in the URI.
application/config/config.php
Change the URI Protocol to PATH_INFO
Add ‘?’ character to Permitted_uri_chars
$this->input->get('x');