Reputation: 1
In my CodeIgniter
controller every Ajax
request checks the token I Passed. If any thing happens wrong I wrote a controller function to destroy all session and logout
'redirect('main/logincontent/load_logout');'
In load_logout function
function load_logout() {
echo "<script>var c=confirm('do you want to continue?');
if(c==true)
{
}
else
{</script>";
$this -> session -> sess_destroy();
echo "<script>window.parent.location.href ='" . base_url() . "';
}</script>";
}
I tried put a confirm box at the beginning of the function load_logout()
. Based on confirm box result user can decide whether to destroy session
and logout or stay Online
.
But it is not working!!!
Any help would be appreciated.
Upvotes: 0
Views: 236
Reputation: 413
you don't need to close script tag each time, try this
echo "<script>var c=confirm('do you want to continue?');
if(c==true){}else{";
$this -> session -> sess_destroy();
echo "window.parent.location.href ='" . base_url() . "';
}</script>";
but it is impossible to destroy session from client side. What you are doing here is just printing these details in client browser. But $this -> session -> sess_destroy(); will not work in browser, because it is server code. You need to add a route to destroy session and call that.
Upvotes: 1