function SetCookie(name,value)
{
var argv=SetCookie.arguments;
var argc=SetCookie.arguments.length;
var expires=(2<argc)?argv[2]:null;
var path=(3<argc)?argv[3]:null;
var domain=(4<argc)?argv[4]:null;
var secure=(5<argc)?argv[5]:false;
document.cookie=name+"="+escape(value)+((expires==null)?"":("; expires="+expires.toGMTString()))+((path==null)?"":("; path="+path))+((domain==null)?"":("; domain="+domain))+((secure==true)?"; secure":"");
}
为什么cookie的最后一个属性secure没有赋值true,请高手指点,万分感谢,另外,菜鸟怎么样才能赚到分

解决方案 »

  1.   

    安全性(secure).是一个布尔值,指定了网络cookie的传输方式,默认的secure值为false,意味着可以通过普通的,不安全的http连接传输.但如果设置为true,那么cookie将只在浏览器通过Https或其他的安全协议才被传输.
      

  2.   

    还是不懂啊,((secure==true)?"; secure":"")   我觉得应该是:((secure==true)?(";secure="+secure):"")
      

  3.   

    cookie的格式是由RFC 2965定义的,http://www.faqs.org/rfcs/rfc2965.html
    Secure
          OPTIONAL.  The Secure attribute (with no value) directs the user
          agent to use only (unspecified) secure means to contact the origin
          server whenever it sends back this cookie, to protect the
          confidentially and authenticity of the information in the cookie.写明不需要值,也就是只要secure(或者就不写)就可以了,不需要 secure=xxx
      

  4.   

    Syntaxdocument.cookie [ = sCookie ]Possible ValuessCookie String that specifies or receives the name=value; pairs, plus any of the values listed in Possible Values. expires=date; Setting no expiration date on a cookie causes it to expire when the browser closes. If you set an expiration date in the future, the cookie is saved across browser sessions. If you set an expiration date in the past, the cookie is deleted. Use GMT format to specify the date.  domain=domainname; Setting the domain of the cookie allows pages on a domain made up of more than one server to share cookie information. 
     
    path=path; Setting a path for the cookie allows the current document to share cookie information with other pages within the same domain—that is, if the path is set to /thispathname, all pages in /thispathname and all pages in subfolders of /thispathname can access the same cookie information. 
     
    secure; Setting a cookie as secure; means the stored cookie information can be accessed only from a secure environment.