简体   繁体   中英

In PHP, how to destroy session and close the window?

I want to close the tab as well as destroy the sessions in the php.

I have this piece of code, but doesn't work well.

<?php
session_start();
session_destroy();
?>

<script language="javascript"> 

setTimeout("self.close();",10000) 

</script>

Help through, Thanks.

Edit: It doesn't close the window as expected.

function openWin()
{
myWindow=window.open("","","width=200,height=100");
myWindow.document.write("<p>This is 'myWindow'</p>");
}

function closeWin()
{
myWindow.close();
}

Hope you have tried to use firefox browser to test

In firefox, You can only close window via JavaScript that have been open via a script window.open() call.

Please refer the below link

Close firefox

Try Internet explorer.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM