Search code examples
phpcodeigniterinputgetopayo

Codeigniter & $_GET variables w/Sagepay


I am integrating Sagepay into my Codeigniter v2.1 application - for some reason I am have issues get the crypt data that is returned from Sagepay within the $_GET querystring.

Whenever I try the variable from the $_GET it returns as FALSE, similarly the $_GET array itself returns a empty array.

The URL is as follows:

http://mydomain.com/packages/payment_status/success/?crypt=IgAdEBkXOhwsHRAATkVESF5RQkNDSEJEW1BWSVpDWVNDQUFXXVJXVCI1ICAOLApZFEJMIUVMRiMvSVoxMFxeMTMjW0kuQDAkXjBGIVoiK0FAUzcwQRhINxsTABAASTkuSDcbEwAQADATEQ8NA09EVUNEVl9OMAcXVCQGAB4KHA0cEwAMHBpWEg8XTyEBBhARBRYIEQNcUjELNQMRBioAT0VVQE1OUFpCLiQnJiVGSzYrJzogPTEqVDUqKiFPPzUxMDxWKiAoNlQ1ARcGExYdNgoBAQkHSTgqOikuJjctNjBQNQEXGzEbARYmExYbCBtPOionOTcxLSwqNlImJUYkAB0RAwZJKDIgNS0rIEk1HQMHNR8BU1RJQTA2FhcDFws3GxMAEABJOCo6Jyc3Ny42MFAmDxYLJg0VFkkgLD0lST4VFgdAMgwJDRsBSVVDREBDLwkABxoRTkZDVUBUXw==

    $crypt = $this->input->get('crypt');
    var_dump($crypt); // returns FALSE

I've turned on the following config settings:

$config['uri_protocol'] = "QUERY_STRING";
$config['enable_query_strings'] = TRUE;
$config['permitted_uri_chars'] = 'a-z 0-9~%.:_\-?'; // to allow the '?' character in the url

Can anyone suggest what I am doing wrong?


Solution

  • Used this method in the end.. MY_Controller.php

    function current_url() {
    $CI =& get_instance();
    
    $url = $CI->config->site_url($CI->uri->uri_string());
    return $_SERVER['QUERY_STRING'] ? $url.'?'.$_SERVER['QUERY_STRING'] : $url;
    

    }

    // in my controller $parts = parse_url(current_url());

        if (isset($parts['query']) && is_array($parts))
        {
            parse_str($parts['query'], $querystring);
            krumo($querystring);
        }
    

    This seems to be fine for now :) thanks - have changed the uri setting to PATH_INFO and made some tweaks to the htaccess file too.