Had shared the solution long time ago .. but it comes again .. so enjoy the same :)
/***********Add it in some common helper file and autoload it or manually load it.**********/
if ( ! function_exists('clearSearchCookies'))
{
function clearSearchCookies($thisurl) {
//Check if the referer is not same as this page then clear the cookies
if(array_key_exists('HTTP_REFERER', $_SERVER)) {
$refering_url = $_SERVER['HTTP_REFERER'];
if($refering_url != '') {
if(substr($refering_url, 0, strlen($thisurl)) == $thisurl) {
//Fine to go with .. since it is the same one continued in here
} else {
deleteSearchCookies();
}
} else {
deleteSearchCookies();
}
} else {
deleteSearchCookies();
}
}
}
if ( ! function_exists('deleteSearchCookies'))
{
function deleteSearchCookies() {
foreach ($_COOKIE as $key=>$val) {
if(stripos($key, 'crud_page') !== FALSE) {
delete_cookie($key);
}
if(stripos($key, 'per_page') !== FALSE) {
delete_cookie($key);
}
if(stripos($key, 'hidden_ordering') !== FALSE) {
delete_cookie($key);
}
if(stripos($key, 'search_text') !== FALSE) {
delete_cookie($key);
}
if(stripos($key, 'search_field') !== FALSE) {
delete_cookie($key);
}
}
}
}
/***********One of the function reference from the actual controller.**********/
/**
* Function to manage the retailers
*/
function retailers($parent_retailer_id = 0) {
//Clear the search related cookies if the the url is a fresh hit
clearSearchCookies($thisurl = site_url() . "manage/retailers");
$this->load->library('ajax_grocery_CRUD');
$crud = new ajax_grocery_CRUD();
$crud->set_table('retailers');
......
.....
$this->load->view('retailer_crud', $output);
}
Happy GCing ...