#22003/3/11 9:32:58
这是我写的一个比较简单的使用COOKIES储存商品信息的代码:
购物车:
if trim(request("id"))<>"" then
x=""
stock=request.cookies("sell")("buy")
add=request("id")
If Len(stock) = 0 Then
stock = add&",1|"
else
a=split(stock,"|")
j=ubound(a)
tag=0
for i=0 to j-1
b=split(a(i),",")
if (b(0)=add) then
b(1)=b(1)+1
tag=1
end if
x=x&b(0)&","&b(1)&"|"
next
if tag=1 then
stock=x
else
stock=stock&add&",1|"
end if
End If
response.cookies("sell")("buy")=stock
Response.Cookies("sell").Expires = dateadd("d","1",date())
end if
更改商品数量:
<%
if request("Update")="修改" then
xx=""
stock=""
if request.cookies("sell")("buy")<>"" then
for tt=1 to request("stock_num").count
add=cint(request("stock_num")(tt))
stock=request.cookies("sell")("buy")
ab=split(stock,"|")
bs=split(ab(tt-1),",")
bs(1)=add
xx=xx&bs(0)&","&bs(1)&"|"
next
stock=xx
response.cookies("sell")("buy")=stock
end if
end if%>
收藏夹也是差不多道理
编辑历史:[这消息被germchen编辑过(编辑时间2003-03-11 09:37:29)]