代码之家  ›  专栏  ›  技术社区  ›  Chris Dutrow

Cookies-存储身份验证令牌

  •  0
  • Chris Dutrow  · 技术社区  · 15 年前

    下面是cookie的构造函数。我正在使用restlets,不确定要将“path”和“domain”设置为什么。这些领域的目的是什么?另外,如果我将“secure”设置为“true”,是否意味着如果连接不是https,它不会传输cookie?

    public CookieSetting(int version,
                         String name,
                         String value,
                         String path,
                         String domain,
                         String comment,
                         int maxAge,
                         boolean secure,
                         boolean accessRestricted);
    
    //'secure' - Indicates if cookie should only be transmitted by secure means.
    //'accessRestricted' - Indicates whether to restrict cookie access to untrusted parties.
    //  Currently this toggles the non-standard but widely supported HttpOnly cookie parameter.
    
    1 回复  |  直到 15 年前
        1
  •  1
  •   Purush Rudrakshala    15 年前

    例如,如果设置domain=xyz.com、path=/app和secure=true,浏览器将在调用时发送cookie https://xyz.com/app/

    如果设置了secure=true,则在使用时不会发送cookie http://xyz.com/app 网址。