日期:2014-05-17  浏览次数:20936 次

奇怪的cookies丢失问题
网站:http://sh.ailv.cn
在向购物车增加第12个商品时,三个商品的cookies数据丢失,以后每向购物车增加一个商品,就丢失一个,一直保留8个商品cookies。太奇怪了。

代码如下:
<!--#include   file= "conn.asp "-->
<html>
<head>
<meta   http-equiv= "Content-Type "   content= "text/html;   charset=gb2312 ">
<title> 购物车 </title>
<link   href= "css/css.css "   rel= "stylesheet "   type= "text/css "   />
<style   type= "text/css ">
<!--
body   {
background-color:   #F5E9ED;
}
-->
</style> </head>

<body>
<table   width= "563 "   height= "174 "   border= "0 "   cellpadding= "0 "   cellspacing= "8 "   bgcolor= "FFDEEA ">
    <tr>
        <td   valign= "top "   bgcolor= "#FFFFFF ">
<%
if   request.QueryString( "action ")= "reset "   then
idlist=request.Cookies( "idlist ")
idlist1=request.Form( "id ")
id=split(idlist, ", ")
id1=split(idlist1, ", ")

'删除选购商品
for   i=0   to   ubound(id)
if   len(id(i))> 0   then
del=true
for   j=0   to   ubound(id1)
if   clng(id1(j))=clng(id(i))   then
del=false
exit   for
end   if
next
if   del   then
response.Cookies( "pro "&id(i)).expires= "1/1/1998 "
end   if
end   if
next

'修改选购商品定购件数
dim   errmsg,cnum
for   j=0   to   ubound(id1)
keyname=clng(id1(j))
cnum=clng(request.Form( "m_ "&keyname))
if   cnum=0   then
errmsg= "修改数量失败,订单商品数量为0! "
else
response.Cookies( "pro "&keyname)( "num ")=cnum
end   if
next
response.Cookies( "idlist ")=idlist1& ", "
if   len(errmsg)> 0   then
response.Write( " <script   language=javascript> alert( ' "&errmsg& " ');location.href= 'buy.asp '; </script> ")
response.End()
else
response.Redirect( "buy.asp ")
end   if
elseif   request.QueryString( "action ")= "clear "   then
idlist=request.Cookies( "idlist ")
id=split(idlist, ", ")
for   i=0   to   ubound(id)
if   len(trim(id(i)))> 0   then
keyname= "pro "&clng(id(i))
response.Cookies(keyname).expires= "1/1/1998 "
end   if
next
response.Cookies( "idlist ")= " "
response.Redirect( "buy.asp ")
elseif   request.QueryString( "id ") <> " "   then
proid=clng(request.QueryString( "id "))
set   rs=server.CreateObject( "adodb.recordset ")
rs.open   "select   *   from   v_uid_pro   where   uid= "&request.Cookies( "uid ")& "   and   isview=1   and   id= "   &   proid,conn,1,1

idlist=request.Cookies( "idlist ")
id=split(idlist, ", ")
have=fal