HttpCookie SetVersion() Example
Sets the version of the cookie protocol this cookie complies with.
HttpCookieclass SetVersion() method example. This example shows you how to use SetVersion() method.This method Sets the version of the cookie protocol this cookie complies with.
Here is the code:-
/*
* @Program that Sets the version of the cookie protocol this cookie complies with.
* SetVersion.java
* Author:-RoseIndia Team
* Date:-25-Jun-2008
*/
import java.net.*;
public class SetVersion {
public static void main(String[] args) throws Exception {
String name = "Roseindia";
String value = "ABC";
HttpCookie hc = new HttpCookie(name, value);
//Returns the version of the protocol this cookie complies with.
System.out.println("Version of the protocol is: " + hc.getVersion());
//Sets the version of the cookie protocol this cookie complies with.
hc.setVersion(0);
System.out.println("Version of the protocol is: " + hc.getVersion());
}
} |
Output of the program:-
Version of the protocol is: 1
Version of the protocol is: 0 |
|