Example usage for java.net CookiePolicy ACCEPT_ORIGINAL_SERVER

List of usage examples for java.net CookiePolicy ACCEPT_ORIGINAL_SERVER

Introduction

In this page you can find the example usage for java.net CookiePolicy ACCEPT_ORIGINAL_SERVER.

Prototype

CookiePolicy ACCEPT_ORIGINAL_SERVER

To view the source code for java.net CookiePolicy ACCEPT_ORIGINAL_SERVER.

Click Source Link

Document

One pre-defined policy which only accepts cookies from original server.

Usage

From source file:Main.java

public static void main(String[] args) throws Exception {
    CookieManager cm = new CookieManager();
    cm.setCookiePolicy(CookiePolicy.ACCEPT_ORIGINAL_SERVER);
    CookieHandler.setDefault(cm);

    new URL("http://google.com").openConnection().getContent();

    List<HttpCookie> cookies = cm.getCookieStore().getCookies();
    for (HttpCookie cookie : cookies) {
        System.out.println("Name = " + cookie.getName());
        System.out.println("Value = " + cookie.getValue());
        System.out.println("Lifetime (seconds) = " + cookie.getMaxAge());
        System.out.println("Path = " + cookie.getPath());
        System.out.println();//from   w  w w.ja  v a2s.  c o m
    }
}

From source file:se.leap.bitmaskclient.ProviderAPI.java

@Override
public void onCreate() {
    super.onCreate();

    preferences = getSharedPreferences(Dashboard.SHARED_PREFERENCES, MODE_PRIVATE);
    CookieHandler.setDefault(new CookieManager(null, CookiePolicy.ACCEPT_ORIGINAL_SERVER));
}