i have written this code in order to set a cookie and then make it expire as the user leaves the page:

<script>document.cookie ='chat=sesion; path=index.php';</script>
<script language="javascript">
function clearCookie(){
 document.cookie='chat=;expires=Thu, 01-Jan-70 00:00:01 GMT;';
window.onunload = clearCookie;
It works fine on Firefox and Chrome but as usual not on IE (its a piece of shit, you know). Could anybody please recommend me a cross-browser solution?

Thank you.