我想在持有身份验证令牌的客户端上放置一个cookie。用他们的凭据登录后,他们只能发送令牌而不是凭据,直到服务器确定令牌已过期。
以下是cookie的构造函数。我正在使用restlet并且不确定要将“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.
答案 0 :(得分:1)
例如,如果您设置domain = xyz.com,path = / app和secure = true,浏览器会在调用https://xyz.com/app/时发送Cookie ...
如果设置了secure = true,则在使用http://xyz.com/app网址时不会发送Cookie。