You'd probably have to use AJAX. This is just something I adapted...
var http_request = false;
var url = http://yourdomain.com/phphandler.php;
function makerequest(url) {
var pars = '?';
http_request = false;
if (window.XMLHttpRequest) { // Mozilla, Safari,...
http_request = new XMLHttpRequest();
} else if (window.ActiveXObject) { // IE
try {
http_request = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
http_request = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e) {}
}
}
if (!http_request) {
alert('Error: Cannot create an XMLHTTP instance (AJAX)');
return false;
}
http_request.onreadystatechange = doupdate;
pars += 'jssubmit&par1='+par1+'&par2='+par2;
http_request.open('GET', url+pars, true);
http_request.send(null);
}
You'd have to replace the 'par=par1&par2=par2' with the values from your JS script. Then you have a PHP script which grabs the GET variables and saves them as SESSION/COOKIE variables.