Javatpoint Logo
Javatpoint Logo

Java HttpCookie setDiscard() Method

The setDiscard(boolean discard) method of Java HttpCookie class is used to specify whether the given user agent can discard the cookie unconditionally or not. This attribute is RFC 2965 only.

Syntax

Parameter

The above method consist of only one parameter:

  1. discard- simply indicates true to discard the cookie.

Return

N.A.

Example 1

Test it Now

Output:

Checks the discard attribute of cookie: false

Example 2

Test it Now

Output:

Checks the discard attribute of the cookie: true

Example 3

Test it Now

Output:

Comment1: Discard attribute is not present.
Comment2: Discard attribute is present.
Next TopicsetDomain() Method





Youtube For Videos Join Our Youtube Channel: Join Now

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA