Results 1 to 5 of 5

Thread: Array of, cookies?

  1. #1

    Thread Starter
    Fanatic Member invitro's Avatar
    Join Date
    Jan 2000
    Location
    Outside your window
    Posts
    547

    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?

  2. #2
    Big D Danial's Avatar
    Join Date
    Jul 2000
    Location
    ASP.Net Forum
    Posts
    2,877
    Hi Alek,
    Its me again ,

    This thread should be what you are looking for..

    http://forums.devshed.com/showthread...574#post764574

    Look at the link on the last post too.
    [VBF RSS Feed]

    There is a great war coming. Are you sure you are on the right side? Atleast I have chosen a side.

    If I have been helpful, Please Rate my Post. Thanks.

    This post was powered by :

  3. #3

    Thread Starter
    Fanatic Member invitro's Avatar
    Join Date
    Jan 2000
    Location
    Outside your window
    Posts
    547
    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?

  4. #4

    Thread Starter
    Fanatic Member invitro's Avatar
    Join Date
    Jan 2000
    Location
    Outside your window
    Posts
    547
    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?

  5. #5
    Big D Danial's Avatar
    Join Date
    Jul 2000
    Location
    ASP.Net Forum
    Posts
    2,877
    Told you I am powered by Google

    See why i prefer storing items in the DB in temp Table. Its might be extra resources on the server but you can be more flexible that way, and seeing which items user added to cart is valuable to justify the extra server resource use.

    Make sure you check that users dont have cookies disabled or your cart will stop working.

    Good luck.
    [VBF RSS Feed]

    There is a great war coming. Are you sure you are on the right side? Atleast I have chosen a side.

    If I have been helpful, Please Rate my Post. Thanks.

    This post was powered by :

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width