HttpCookie GetSecure() Example

Started by VelMurugan, Dec 24, 2008, 10:05 PM

Previous topic - Next topic

VelMurugan

HttpCookie GetSecure() Example

Returns true if the browser is sending cookies only over a secure protocol,

HttpCookieclass GetSecure() method example. This example shows you how to use GetSecure() method.This method Returns true if the browser is sending cookies only over a secure protocol,

Here is the code:-

/*
* @Program that Returns true if the browser is sending cookies only over a
    secure protocol
* GetSecure.java
* Author:-RoseIndia Team
* Date:-25-Jun-2008
*/

import java.net.*;

public class GetSecure {

    public static void main(String[] args) throws Exception {
        String name = "Roseindia";
        String value = "ABC";
        HttpCookie hc = new HttpCookie(name, value);
        hc.setSecure(true);
        // Returns true if the browser is sending cookies only over a secure protocol
        System.out.println("Browser is sending cookies: "+hc.getSecure());
    }
}


Output of the program:-

Browser is sending cookies: true

Source : codingdiary