php - clearing two dimensional session array using jsp
i have a two dimensional session array and i'm trying to clear it after the bill is printed. to do so i'm using this code
<script type="text/javascript">
function textsizer(e) {
var evtobj=window.event? event : e;
var element = evtobj.target ? evtobj.target : evtobj.srcElement;
if (element.tagName.toLowerCase() == "body") {
var unicode=evtobj.charCode? evtobj.charCode : evtobj.keyCode;
var actualkey=String.fromCharCode(unicode)
if(actualkey=="x"){
show_confirm()
function show_confirm(){
var con = confirm("Are You Sure you wan to cancel this bill?");
if (con ==true){
session.invalidate();
}
else{
alert("You pressed Cancel!");
}
}
}
}
}
document.onkeypress=textsizer
</script>
but this code is not clearing the session. i tried it using google chrome and internet explorer but didn't work. can anyone help me on this thing? i also tried to do it with php but it also didn't work for me. my case i want to delete session by pressing x on key board there is no matter what is the language, i just want to clear the session pressing x key
Answer
Solution:
You could use JavaScript to capture when the 'x' key is pressed, and redirect to a PHP page to clear the session. So you want something along the lines of: