0

我想在持有身份验证令牌的客户端上放置一个 cookie。在他们使用凭据登录后,他们可以只发送令牌而不是凭据,直到服务器确定令牌已过期。

下面是 cookie 的构造函数。我正在使用restlets,不确定将“路径”和“域”设置为什么。这些领域的目的是什么?另外,如果我将“安全”设置为“真”,这是否意味着如果连接不是 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.
4

1 回答 1

1

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

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

于 2010-10-20T21:48:58.027 回答