Java HttpCookie setDomain() Method

The setDomian(String pattern)method of HttpCookie class is used to specify the domain through which the cookie can be presented.

Syntax

Parameter

The above method requires only one parameter:

  1. pattern - which denotes a string which contains the domain name within which the cookie is visible.

Return

N.A.

Example 1

Test it Now

Output:

The domain name is given as: www.google.com

Example 2

Test it Now

Output:

The first domain name is given as: www.localhost.com
The second domain name is given as: www.google.com 

Example 3

Test it Now

Output:

The domain name is given as:  null 




Latest Courses