Skip to content

Enable GET method in CodeIgniter Framework?

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 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');
0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Most Voted
Newest Oldest
Inline Feedbacks
View all comments