【www.gdgbn.com--php函数】

我们利用readcookie来读取,利用setcookie设置或删除cookie值。
*/

function readcookie ( cookiename )
    {
        var thecookie=""+document.cookie;
        var ind=thecookie.indexof(cookiename);
        if (ind==-1 || cookiename=="") return "";
        var ind1=thecookie.indexof(";",ind);
        if (ind1==-1) ind1=thecookie.length;
        return unescape(thecookie.substring(ind+cookiename.length+1,ind1));
    }

    function setcookie(cookiename,cookievalue,ndays)
    {
        var today = new date();
        var expire = new date();
        if (ndays==null || ndays==0) ndays=1;
        expire.settime(today.gettime() + 3600000*24*ndays);
        document.cookie = cookiename+"="+escape(cookievalue)
                     + ";expires="+expire.togmtstring();
   

 }

本文来源:http://www.gdgbn.com/jiaocheng/28789/