public interface CookieStorage
BrowserPreferences.getDefaultChromiumDir()
method.
So, if Browser A and B have the same cache directory, then they will access the cookies of each other.
If you need to configure each Browser to use unique cookie storage which is not accessible for other Browser instances, you need to provide unique user data directory for each Browser instance. The user data directory path can be provided via configured
BrowserContextParams.BrowserContextParams(String)
object that must be passed into the
Browser.Browser(BrowserContext)
factory method.
Modifier and Type | Method and Description |
---|---|
boolean |
delete(Cookie cookie)
Deletes one specific
删除一个特定的cookie。 cookie .
|
int |
deleteAll()
Deletes all of the cookies including session, secure or HTTP only cookies.
删除所有cookie,包括会话cookie,安全cookie或仅HTTP cookie。 |
java.util.List<Cookie> |
getAllCookies()
Returns all the cookies including secure and HTTP only cookies.
返回所有cookie,包括安全cookie和仅HTTP cookie。 |
java.util.List<Cookie> |
getAllCookies(java.lang.String url)
Returns all the cookies for given
返回给定URL的所有cookie,包括仅HTTP cookie。 url including HTTP only cookies.
|
void |
save()
Use this method to save all the changes you apply to this cookie storage.
使用此方法可保存您应用于此Cookie存储的所有更改。 |
boolean |
setCookie(java.lang.String url, java.lang.String name, java.lang.String value, java.lang.String domain, java.lang.String path, long expirationTimeInMicroseconds, boolean secure, boolean httpOnly)
Sets a cookie given explicit user-provided cookie attributes and associate it with the given
设置一个具有明确的用户提供的cookie属性的cookie,并将其与给定的url关联。 url .
|
boolean |
setSessionCookie(java.lang.String url, java.lang.String name, java.lang.String value, java.lang.String domain, java.lang.String path, boolean secure, boolean httpOnly)
Sets a session cookie given explicit user-provided cookie attributes and associate it with the given
根据给定的显式用户提供的cookie属性设置会话cookie,并将其与给定的url关联。 url .
|
java.util.List<Cookie> getAllCookies()
java.util.List<Cookie> getAllCookies(java.lang.String url)
url
including HTTP only cookies.
url
- the URL associated with the returned cookies.
-与返回的Cookie关联的URL。
boolean delete(Cookie cookie)
cookie
. The cookie instance can be received from a list of cookies returned from the
getAllCookies()
method.
cookie
- cookie to delete.
-要删除的Cookie。
true
when cookie was deleted successfully.
成功删除Cookie的时间。
int deleteAll()
boolean setCookie(java.lang.String url, java.lang.String name, java.lang.String value, java.lang.String domain, java.lang.String path, long expirationTimeInMicroseconds, boolean secure, boolean httpOnly)
url
.
This method expects each cookie attribute to be well-formed. It will check for disallowed characters (e.g. the ';' character is disallowed within the cookie value attribute) and will return false without setting the cookie if such characters are found.
If
url
and
domain
are different, the cookie will not be set and the method returns
false
. So, make sure that
url
and cookie domain are the same domains. For example, for
http://www.teamdev.com
address the cookie domain must be
.teamdev.com
If you set the cookie successfully and the method returns
true
and you decide to find the
cookie
in the list of all cookies, please note that the cookie storage can modify some cookies attributes such as domain or expiration time.
url
- a string that represents a valid URL which host will be associated with a new cookie instance. The url string must be valid and has the following format: http[https]://host. For example, http://www.google.com, https://www.gmail.com etc.
-表示有效URL的字符串,该主机将与新的cookie实例相关联。 url字符串必须有效,并且具有以下格式:http [https]:// host。例如,http://www.google.com、https://www.gmail.com等。
name
- the cookie name.
-Cookie名称。
value
- the cookie value.
-Cookie值。
domain
- the cookie domain. For example, ".google.com".
-Cookie域。例如,“。google.com”。
path
- the cookie path. For example, "/".
-Cookie路径。例如, ”/”。
expirationTimeInMicroseconds
- the expiration time in microseconds.
-到期时间(以微秒为单位)。
secure
- indicates whether cookie is secure.
-表示cookie是否安全。
httpOnly
- indicates whether cookie is HTTPOnly.
-表示cookie是否为HTTPOnly。
true
when cookie was inserted successfully, otherwise -
false
. If the passed cookie is valid but already expired, the method returns
true
, but the cookie will not be in the list of all cookies.
成功插入cookie时,否则-。如果传递的cookie有效但已过期,则该方法返回,但该cookie不会在所有cookie的列表中。
boolean setSessionCookie(java.lang.String url, java.lang.String name, java.lang.String value, java.lang.String domain, java.lang.String path, boolean secure, boolean httpOnly)
url
.
This method expects each cookie attribute to be well-formed. It will check for disallowed characters (e.g. the ';' character is disallowed within the cookie value attribute) and will return false without setting the cookie if such characters are found.
If
url
and
domain
are different, the cookie will not be set and the method returns
false
. So, make sure that
url
and cookie domain are the same domains. For example, for
http://www.teamdev.com
address the cookie domain must be
.teamdev.com
If you set the cookie successfully and the method returns
true
and you decide to find the
cookie
in the list of all cookies, please note that the cookie storage can modify some cookies attributes such as domain or expiration time.
url
- a string that represents a valid URL which host will be associated with a new cookie instance. The url string must be valid and has the following format: http[https]://host. For example, http://www.google.com, https://www.gmail.com etc.
-表示有效URL的字符串,该主机将与新的cookie实例相关联。 url字符串必须有效,并且具有以下格式:http [https]:// host。例如,http://www.google.com、https://www.gmail.com等。
name
- the cookie name.
-Cookie名称。
value
- the cookie value.
-Cookie值。
domain
- the cookie domain. For example, ".google.com".
-Cookie域。例如,“。google.com”。
path
- the cookie path. For example, "/".
-Cookie路径。例如, ”/”。
secure
- indicates whether cookie is secure.
-表示cookie是否安全。
httpOnly
- indicates whether cookie is HTTPOnly.
-表示cookie是否为HTTPOnly。
true
when session cookie was inserted successfully, otherwise -
false
.
成功插入会话cookie时,否则-。
void save()