Forum Moderators: open

Message Too Old, No Replies

Cookies

modifying to create a shopping basket

         

bateman_ap

10:13 am on Jun 17, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I am trying to make a simple shopping basket in taditional asp. I have created a cookie to store all the items added to the basket by referencing their uid numbers. However I need to also add the quantity of each and this is causing some problems.

At the moment the cookie looks like
uid1=1&uid2=1

I was thinking the =1 should reflect the quantity so every time a item was added with that uid it increments by 1. Also there should be a way to subtract it by 1 upon someone clicking the subtract link.

The code that currently sets the cookie is

uid = request.querystring("id")
cookieUid = "uid" & uid
Response.Cookies("short")(cookieUid) = "1"
response.redirect "shop.asp"

Anyone got an idea of how to achieve this?

Many thanks

Easy_Coder

3:31 am on Jun 19, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



It would be much cleaner if the cookie contained your unique shopper guid that had a one to many relationship with a basket table.

Here's a crude example:

cookie
=======
GUID.....xyz

basket sku qty
=========================
GUID.....xyz 123456 1
GUID.....xyz 987654 3

bateman_ap

9:01 am on Jun 19, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I was thinking that, reading up on a few sites some people had recommended the cookie option as it isn't putting as much stress on the server. What do you think?

Easy_Coder

10:01 am on Jun 19, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I would go with the basket table. Database tables are perfect for managing this type of solution.

mattglet

10:44 am on Jun 19, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



bateman-

Just make sure you can encrypt your ID in the cookie, or at least don't tie any personal info to the ID without some security. If I choose to view the cookie you place on my computer, and I change the ID to something else, I should not be able to view anyone else's personal details.