document.cookie="userId=828";
document.cookie="userName=hulk";
//Get cookie string
var strCookie=document.cookie;
//Cut multiple cookies into multiple name/value pairs
var arrCookie=strCookie.split("; ");
var userId;
//Traverse the cookie array and process each cookie pair
for(var i=0;i<arrCookie.length;i){
var arr=arrCookie[i].split("=");
//Find the cookie named userId and return its value
if("userId"==arr [0]){
userId=arr[1];
break;
}
}
alert(userId) ;