document.cookie = name + "=" + value + "; path=/; domain=yahoo.com";
这个cookies为什么我在cookies文件夹下找不到?

解决方案 »

  1.   

    这里有一个有效期问题,默认是页面关闭。
    若设置了足够的有效期,在页面关闭时document.cookie的内容才会被写入文件
      

  2.   

    那cookies的信息是保存在客户机上还是服务器上,可以在客户机上更改吗?
      

  3.   

    保存在客户端,在客户机上可以改;你用这个函数在cookies文件夹下就看得到了:
    这是个VBscript函数,Cookie的有效期为1天;Sub SetCookie(strCookieName,strCookieValue)
    Dim strTemp
    strTemp=strCookieName & "=" & strCookieValue
    strTemp=strTemp & ";expires=" & Weekday(Date,vbUseSystem) & ","
    strTemp=strTemp & Day(Date)+1 & "-" 
    strTemp=strTemp & Month(Date) & "-" 
    strTemp=strTemp & Year(Date) 
    strTemp=strTemp & " 12:00:00 "
    strTemp=strTemp & " GMT"
    strTemp=strTemp & ";Path=/"
    document.cookie=strTemp
    End Sub
      

  4.   

    gdeljyh(阿江) ,谢谢你的回答
    不过我不懂如何使用这个函数啊
      

  5.   

    这样用:
    strCookieName是变量名,strCookieValue 是你要赋给strCookieName的值;
    赋值后用函数GetCookie就可以读出strCookieName的值了,下面是一个完整的例子:<HTML>
    <HEAD>
    <META name=VI60_defaultClientScript content=VBScript>
    <META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
    <TITLE></TITLE>
    <SCRIPT ID=clientEventHandlersVBS LANGUAGE=vbscript>
    <!--Sub SetCookie(strCookieName,strCookieValue)
    On Error Resume Next
    Dim strTemp
    strTemp=strCookieName & "=" & strCookieValue
    strTemp=strTemp & ";expires=" & Weekday(Date,vbUseSystem) & ","
    strTemp=strTemp & Day(Date)+1 & "-" 
    strTemp=strTemp & Month(Date) & "-" 
    strTemp=strTemp & Year(Date) 
    strTemp=strTemp & " 12:00:00 "
    strTemp=strTemp & " GMT"
    strTemp=strTemp & ";Path=/"
    document.cookie=strTemp
    End Sub Function GetCookie(strCookieName) 
    On Error Resume Next
    Dim strCookie
    Dim intNamePos
    Dim intNameLength 
    Dim intValueLength 
    Dim intNextSemicolon
    Dim strTempCookie
    strCookie=Document.Cookie
    strTempCookie=strCookie
    GetCookie=""
    If strCookieName<>"" Then
    intNamePos=InStr(1,strTempCookie,strCookieName,1)
    intNameLength = Len(strCookieName) 
    Do While intNamePos>0 
    strTempCookie=Right(strTempCookie,Len(strTempCookie)-intNamePos+1)
    If Mid(strTempCookie,intNameLength+1,1)<>"=" Then
    Exit Function
    Else
    intNextSemicolon=InStr(strTempCookie,";")
    If intNextSemicolon=0 Then 
    intNextSemicolon=Len(strTempCookie)+1
    End If
    If intNextSemicolon=(intNameLength+2) Then
    Exit Function
    Else
    intValueLength=intNextSemicolon-intNameLength-2
    GetCookie = Mid(strTempCookie, intNameLength + 2, intValueLength)
    End If
    End If
    intNamePos=InStr(intNamePos+intNameLength,strTempCookie,strCookieName,1)
    Loop
    End If 
    End FunctionCall SetCookie("Name","阿江")
    MsgBox GetCookie("Name")
    -->
    </SCRIPT>
    </HEAD>
    <BODY><P>&nbsp;</P></BODY>
    </HTML>