|
-
Sep 8th, 2004, 08:40 PM
#1
Thread Starter
Fanatic Member
Array of, cookies?
I came across this little problem... see, I want to store products in my cookie like so:
('Product')(intProductID)
Code:
Response.Cookies('Product')(intProductID);
where 'product' is the field in which i locate a product, and intProductID is the value that identifies that product.
I'm sure you can all see the problem with this. Every time i store a cookie in the above statement it overrides the old Product... how can i make some kind of an array or something where it stores
'Product'(id1)(id2)(id3)
or do i actually have to do named values such as
'Product1'(id1)
'Product2'(id2)
and then simply cycle through the cookies using
'Product' + i, where i is the number by which product incriments.
Thanks ladies and gents
ok, so... windows takes 1 minute to search for a file on my PC yet google.com takes 1 second to search the entire internet? 
-
Sep 8th, 2004, 08:45 PM
#2
-
Sep 8th, 2004, 09:05 PM
#3
Thread Starter
Fanatic Member
Cool.. that last link looks appealing since I wont always be storing the products in an array... since the user will want to add them one by one. HMMMmm.... very appealing indeed, im just worried about CPU usage on that function, since the server is going to do all the spliting.
Also, there is no split function in Javascript... ill have to come up with something.
There would also have to be a remove function in there incase users wanted to get rid of stuff... and quantity... i would have to store quantity as well... HMmmm....
Thanks for the reply Dan, ur a life saver
ok, so... windows takes 1 minute to search for a file on my PC yet google.com takes 1 second to search the entire internet? 
-
Sep 8th, 2004, 09:16 PM
#4
Thread Starter
Fanatic Member
Ok that was way too simple. I just rewrote it, heres code incase anyone is looking to do this in Jscript
Code:
function addItem(pID)
{
var strProduct;
strProduct = Request.Cookies("product")("list");
strProduct += (strProduct + ",");
Response.Cookies("product")("list") = strProduct;
}
function getProducts()
{
'This code will put the favorites into an array
var arrProductList;
var strProducts;
strProducts = Request.Cookies("product")("list");
arrProductList = strProducts.split(",");
return arrProducts;
}
Last edited by invitro; Sep 9th, 2004 at 08:03 PM.
ok, so... windows takes 1 minute to search for a file on my PC yet google.com takes 1 second to search the entire internet? 
-
Sep 8th, 2004, 09:16 PM
#5
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|