I have a problem with Javascript event OnUnload. I want to update a record in a database as many times as onunload event is called. I have that code for do this:

ajax.js
PHP Code:
function MyAjax() {
var 
xmlhttp=false;
try {
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
} catch (
e) {
try {
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
} catch (
E) {
xmlhttp false;
}
}

if (!
xmlhttp && typeof XMLHttpRequest!='undefined') {
xmlhttp = new XMLHttpRequest();
}

return 
xmlhttp;
}

function 
ClearHTML(sHTML) {
sHTML sHTML.replace(/<[^>]*>/gi"");
sHTML sHTML.replace( /\n/gi"") ;
sHTML sHTML.replace(/&nbsp;/gi"");

return 
sHTML;

borrar_temp.php

PHP Code:
<?
session_start
();
require_once(
"inc/functions.inc.php");
require_once(
"inc/sections.inc.php");
require_once(
"inc/conection.inc.php");

$Hoy=date("Y-m-d")." ".date("H:m:s");
$sql="update sesiones set session_destroy='".$Hoy."' WHERE session_id='".$_SESSION['IdSession']"'";
mysql_query($sql);
session_destroy();


?>
index.php

PHP Code:
<html>

<
head><script language="javascript" src="js/ajax.js" type="text/javascript"></script>
<
script language="Javascript" type="text/javascript">
//Función para guardar tu informacion en bd utilizando ajax.
function cargarContenido()
{
var 
miAjaxObj MyAjax();
miAjaxObj.open("GET","borrar_temp.php",true);
miAjaxObj.send(null);
alert("ejecutado");
}

</
script></head>

<
body onunload="cargarContenido();">
</
body>
</
html
The result of that is that the Javascript makes ok, but php code no...

Thanks!!