Java HttpCookie setDiscard() 方法

2025 年 3 月 22 日 | 阅读需 2 分钟

Java HttpCookie 类的 setDiscard(boolean discard) 方法用于指定给定的用户代理是否可以无条件丢弃此 Cookie。此属性仅用于 RFC 2965。

 

语法

参数

上述方法仅包含一个参数

  1. discard - 如果为 true,则表示丢弃 Cookie。

返回

不适用。

示例 1

输出

Checks the discard attribute of cookie: false

示例 2

输出

Checks the discard attribute of the cookie: true

示例 3

输出

Comment1: Discard attribute is not present.
Comment2: Discard attribute is present.
下一个主题setDomain() 方法