куки
function setCookie(name,value,options){options=options||{};var expires=options.expires;if(typeof expires=="number"&&expires){var d=new Date();d.setTime(d.getTime()+expires*1000);expires=options.expires=d;}
if(expires&&expires.toUTCString){options.expires=expires.toUTCString();}
value=encodeURIComponent(value);var updatedCookie=name+"="+value;for(var propName in options){updatedCookie+="; "+propName;var propValue=options[propName];if(propValue!==true){updatedCookie+="="+propValue;}}
document.cookie=updatedCookie;}
function getCookie(name){
var matches = document.cookie.match(new RegExp("(?:^|; )" + name.replace(/([\.$?*|{}\(\)\[\]\\\/\+^])/g, '\\$1') + "=([^;]*)"));return matches ? decodeURIComponent(matches[1]) : undefined;}
function deleteCookie(name,p){if(p==true){setCookie(name,'',{expires:-1,path:'/'});}else{setCookie(name,'',{expires:-1});}}
setCookie("cookname", "somecookvalue", {expires: 31104000,path: '/'});
var zz = getCookie("cookname2");
deleteCookie('cook6',true);
deleteCookie('cook7');
ajax
function getXmlHttp(){var xmlhttp;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 showtest1(){
var xmlhttp = getXmlHttp();
    xmlhttp.open('GET', '/target/url/', true);
    xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    xmlhttp.send(null);
    xmlhttp.onreadystatechange = function(){
    if(xmlhttp.readyState == 4){
            if(xmlhttp.status == 200){
            if(xmlhttp.responseText!=''){
            var r=xmlhttp.responseText;
            r=JSON.parse(r);
            /*work with it*/
            }
        }
    }
    };
}
function showtest2(){
var xmlhttp = getXmlHttp();
    xmlhttp.open('POST', '/ajax/downline/', true);
    xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    var sendinfo="id="+777;
    xmlhttp.send(sendinfo);
    xmlhttp.onreadystatechange = function(){
    if(xmlhttp.readyState == 4){
            if(xmlhttp.status == 200){
            if(xmlhttp.responseText!=''){
            var r=xmlhttp.responseText;
            r=JSON.parse(r);
            /*work with it*/
            }
        }
    }
    };
}
тут true про куки
тут true про ajax