Page 1 of 1

cookies

Posted: Wed Apr 16, 2003 1:34 pm
by nincha
can some one show me how to remove a cookie in JS thnx.

Posted: Thu Apr 17, 2003 12:37 am
by nincha
ok forget about removing the cookie, i got another problem that i really need help in.
Here Is my function to set a cookie.

Code: Select all

function setCookie()
{
//info are set into array item
var item = new Array(ite1,ite2,ite3,ite4,ite5,ite6,ite7,ite8,ite9,ite10,ite11,ite12,ite13,ite14,ite15,ite16,
ite15,ite16,ite15,ite16,ite17,ite18,ite19,ite20,ite21,ite22,ite23,ite24,ite25);

var price = new Array(pric1,pric2,pric3,pric4,pric5,pric6,pric7,pric8,pric9,pric10,pric11,pric12,
pric13,pric14,pric15,pric16,pric17,pric18,pric19,pric20,pric21,pric22,pric23,pric24,pric25);

num=0
the_cookie="";
for(count=0;count<25;count++)
	&#123;
	if(item&#1111;count].length>1)
		&#123;
		the_cookie = the_cookie+item&#1111;count]+"&"+price&#1111;count]+"/";
		num++; //just a count on how many items is saved
		&#125;
	&#125;


	if(num!=0)
	&#123;

	var d = new Date()
	d2 = d.getDate();
	d2 = d2 + 2;
	d.setDate(d2)
	document.cookie = "shopping_cart=" + escape(the_cookie)+ ";expires="+ d;
	alert("Your item will be save up to 48 hours");
	&#125;

	else
	&#123;
	alert("There are no items in the shopping cart.");
	&#125;

&#125;
After i alter or update cookie shopping_cart , the cookie will have two shopping_cart="stuff". sence i have two now, i treally mess my code up, those any one have a clue that can help, thnx