The code below is a copy and paste example of cookies in asp and javaclientscript. The cookie is set with a name, array of item names and an array of item values.
An expire date is not given as it is fixed on current date + 50 months.
<%@enablesessionstate="false" language="vbscript"%>
<% ' @enablesessionstate is to disable session %>
<% Response.CacheControl = "no-cache" %>
<% Response.AddHeader "Pragma", "no-cache" %>
<% Response.Expires = -1 %>
<html>
<head></head>
<body>
<%
dim lng_Count
if Request.Cookies("CartItem1"

("ItemID"

= "" then
'simulate a 'cart of items
randomize
for lng_Count = 1 to 10
Response.Cookies("Cart;Item" & lng_Count)("ItemID"

= "GLS;" & (330 + lng_Count)
Response.Cookies("Cart;Item" & lng_Count)("ItemName"

= "VisionCo Glasses " & lng_Count
Response.Cookies("Cart;Item" & lng_Count)("ItemCost"

= round(rnd*10+1,2)
Response.Cookies("Cart;Item" & lng_Count)("ItemQuantity"

= int(rnd*3)
'etc
next
else
lng_Count = 1
while Request.Cookies("CartItem" & lng_Count)("ItemID"

<> ""
Response.Write Request.Cookies("CartItem" & lng_Count)("ItemID"

%><br>
<%=Request.Cookies("Cart;Item" & lng_Count)("ItemName"

%><br>
<%=Request.Cookies("Cart;Item" & lng_Count)("ItemCost"

%><br>
<%=Request.Cookies("Cart;Item" & lng_Count)("ItemQuantity"

%><br>
<% lng_Count = lng_Count + 1
wend
end if
%>
<textarea style="width:600;height:400" id=t1 name=t1></textarea>
<script>
function cookies(strName) {
}
cookies.prototype.del =function(strName){
// to delete a cookie make a string like so:
// cookiename=; expires= dateInThePast.toGMTString()
// this wil return true if the cookiename does not exsist
var blnReturn = false;
var expires = new Date();
expires.setMonth(expires.getMonth()-1);
document.cookie = escape(strName) + "=gone; expires=" + expires.toGMTString();
return !this.get(strName,""

[0];
}
cookies.prototype.add =function(strName,arrItemNames,arrItemValues){
// to create a cookie:
// make a string like this:
// name=value value should be a set of names and values
// name=nameOfValue1=value1&nameOfValue2=value2
// this wil return true if the cookiename exsists
if(arrItemNames.length!=arrItemValues.length||arrItemNames.length==0) { return false;}
var expires = new Date();
var strCookie = escape(strName) + "=";
expires.setMonth(expires.getMonth()+50);
for(i=0;i<arrItemNames.length;i++) {
strCookie = strCookie + escape(arrItemNames[ i ]) + "=" + escape(arrItemValues[ i ]) + "&";
}
strCookie = strCookie.substring(0,strCookie.length-1);
this.del(strName);
document.cookie = strCookie + "; expires=" + expires.toGMTString();
return this.get(strName,""

[0];
}
cookies.prototype.change =function(strName, strItemName, strValue){
// this wil true true if the strName and strItemName exist.
//
var arrRet = this.get(strName,strItemName);
var arrTemp = new Array();
var arrItemNames = new Array();
var arrItemValues = new Array();
var strTemp = "";
if(arrRet.length==2) {
return arrRet;
}
arrTemp = document.cookie.split("; "

;
for(i=0;i<arrTemp.length;i++){
if(arrTemp[ i ].substring(0,strName.length)==strName) {
arrTemp=arrTemp[ i ].substring(strName.length+1,arrTemp[ i ].length).split("&"

;
for(j=0;j<arrTemp.length ;j++){
arrItemNames[j]=unescape(arrTemp[j].split("="

[0]);
arrItemValues[j]=unescape(arrTemp[j].split("="

[1]);
}
break;
}
}
for(i=0;i<arrItemNames.length;i++) {
if(arrItemNames[ i ]==strItemName) {
arrItemValues[ i ] = strValue;
break;
}
}
this.add(strName,arrItemNames,arrItemValues)
return this.get(strName,strItemName);
}
cookies.prototype.get =function(strName, strItemName){
// to get a cookie you need the name of the cookie
// and the name of the item of the cookie
// Request.Cookies cookie(cookiename)(itemname) in asp
var strCookie = document.cookie
var arrCookie = document.cookie.split("; "

;
var tmpArr = new Array();
var arrCookieItem = new Array();
var tmpString = "";
var arrRet = new Array(false,false);
for(i=0;i<arrCookie.length;i++) {
tmpArr = arrCookie[ i ].split("="

;
if(unescape(tmpArr[0])==strName){
tmpString = tmpArr[0];
tmpArr = arrCookie[ i ].substring(tmpString.length+1,arrCookie[ i ].length).split("&"

;
tmpString = tmpArr.join("="

;
tmpArr = tmpString.split("="

;
arrCookieItem = tmpArr;
arrRet[0] = true;
break;
}
//this.del(unescape(tmpArr[ i ]));
}
if(strItemName==""

{arrRet[1]=false;return arrRet;}
if(!arrRet[0]){ //cookie name was not found, check if the name of the cookie item can be found
for(i=0;i<arrCookie.length;i++) {
tmpArr = arrCookie[ i ].split("="

;
for(j=0;j<tmpArr.length;j++){
if(unescape(tmpArr[j]).substring(unescape(tmpArr[j]).length-strItemName.length,unescape(tmpArr[j]).length)==strItemName) {
arrRet[1] = true;
break;
}
}
}
}
for(i=0;i<arrCookieItem.length;i++) {
if(unescape(arrCookieItem[ i ])==strItemName) {
arrRet[0] = unescape(arrCookieItem[i+1]);
arrRet[1] = true;
arrRet = arrRet.slice(0,1);
break;
}
}
// there is no coockie found so we return false
return arrRet;
}
// we wil makke a cookies object that we can use to make/edit/get and delete cookies
var cookies = new cookies();
// the first function of the cookies object that we wil do is the add
// function this function needs a cookie name
// and 2 arrays an array containing the names of the cookie sub items
// and an array that contains the values of the cokie sub items
// this function wil return true if the cookie name exsists after creating it
var arrItemNames = new Array("tst item 1","tst item 2"

;
var arrItemValues = new Array("tst value item 1","tst value item 2"

;
alert('cookie add returns: ' + cookies.add('test cookie',arrItemNames,arrItemValues));
// next we wil use the get function of the cookies object, we want to have
// the cookiename/subitem of that cookie, this function returns an array 2 booleans
// if something goes wrong. The first indicates if the cookiename exsists
// and the second indicates if a subitem exsists with the name you provided.
// if the function can find a value it ruturns an array with only 1 item
// so the array.length will be 1 and the value is in array[0]
//alert('Cannot get this cookie because the subitem does not exists\nso this function returns: ' + cookies.get("test cookie","subitem does not exsists"

);
//alert('this is better, now the function returns the value : ' + cookies.get("test cookie","tst item 1"

[0]);
// the change function of the cookies object wil change a sertain subitem of a cookie
// this function takes the name of the cookie, name of the subitem
// and the new value of the subitem (value it wil be changed to
// the function returns the same as the function get
//alert('Cannot change cookie because cookiename does not exists\nso this function returns: ' + cookies.change("this is an incorrect cookie name","tst item 2","value is errelevant because it is not set"

);
//alert('this is better, now the function returns the value : ' + cookies.change("test cookie","tst item 2","changed this value"

[0]);
// the last function of the cookies object is del this deletes the cookie
// It takes one variable and that is the cookie name
// it returns true if the cookie name still exsists after executing
// and false if the cookiename does not excists
//alert('This cookie probebly did not exist even before the del was started del wil return true because the cookie does not exist ' + cookies.del("this is an incorrect cookie name"

);
//alert('This cookie does exsist but not anymore after the del function is started so del returns allso true: ' + cookies.del("test cookie"

);
document.getElementById('t1').value = document.cookie
</script>
<input value="cookie exist" type=button onclick="alert(cookies.get('tst','item2').join('--'));" id=button1 name=button1>
<input value="cookie change" type=button onclick="alert(cookies.change('tst','item2','this is changed item 2'));;" id=button2 name=button2>
</body>
</html>