Se koden her:
http://www.codebreaker.dk/leg/855294.phpOg koden er her:
<?php
//http://www.eksperten.dk/spm/855294
session_start();
if(isset($_POST['action']) && $_POST['action'] == 'getSession'){
echo json_encode(array('session' => session_id()));
exit();
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "
http://www.w3.org/TR/xhtml1/DTD/strict.dtd"><html xmlns="
http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>GET SESSION</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<script type="text/javascript">
(function(){if(window.XMLHttpRequest)return;var o=null,s,a=["MSXML2.XMLHTTP.5.0","MSXML2.XMLHTTP.4.0","MSXML2.XMLHTTP.3.0","Msxml2.XMLHTTP","Microsoft.XMLHTTP"];for(var i=0,j=a.length;i<j;s=a[i],i++){try{if(o=new ActiveXObject(s))break}catch(e){}}window.XMLHttpRequest=o?function(){return new ActiveXObject(s)}:null;o=null})()
var d=document;
function gE(id){return d.getElementById(id)};
function gA(o,t){return o.getElementsByTagName(t)};
function cE(t){return d.createElement(t)};
function cT(s){return d.createTextNode(s)};
function AjaxReq(sMethod, sUrl, oVars, fnCallBack) {
var oHttp = new XMLHttpRequest();
oHttp.open(sMethod, sUrl, true);
oHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded; charset=utf-8");
oHttp.onreadystatechange = _fnCallBack;
var aQuery = [];
for (var x in oVars) aQuery.push( encodeURIComponent(x) + "=" + encodeURIComponent(oVars[x]) );
oHttp.send( aQuery.join("&") );
aQuery = null;
function _fnCallBack() {
if (oHttp.readyState<4) return;
fnCallBack(oHttp);
oHttp = null;
}
return this;
}
function getSession(){
new AjaxReq("POST", "855294.php", {"action":"getSession"}, getSessionCallBack);
}
function getSessionCallBack(oHttp) {
var oResponse = eval('(' + oHttp.responseText + ')');
alert(oResponse.session);
}
</script>
</head>
<body>
<div>
<a onclick="getSession();" href="#">Get Session</a>
</div>
</body>
</html>