PHP Snippet 1:
$value = $_SESSION["data"];
$query = "SELECT * FROM datas WHERE CONCAT(`code`,`name`, `ID`, `cost`) LIKE '%".$value."%'";
$search = filterTable($query);
if (isset($_SESSION["data"])) {
if (basename($_SERVER['PHP_SELF']) != $_SESSION["data"]) {
session_unset();
}
}
PHP Snippet 2:
unset($_SESSION['data']);
PHP Snippet 3:
$_SESSION = array();
PHP Snippet 4:
session_destroy();
$_SESSION = array();
PHP Snippet 5:
//put this line of code in that page you are planning to refresh.
window.onbeforeunload = function() {
if (typeof XMLHttpRequest != "undefined"){
xmlHttp= new XMLHttpRequest();
}
else if (window.ActiveXObject){
xmlHttp= new ActiveXObject("Microsoft.XMLHTTP");
}
if (xmlHttp==null){
alert("Browser does not support XMLHTTP Request")
return;
}
var base_url="<?php echo base_url(); ?>"
var url=base_url + 'controller/function_name';
// url +=id;
xmlHttp.onreadystatechange = stateChange;
xmlHttp.open("GET", url, true);
xmlHttp.send(null);
};
//your function in php will be
public function function_name(){
$newdata = array(
'session_variable' =>0
);
$this->session->set_userdata($newdata);
}