Work with cookies

You can use use Android utilities to write arbitrary data to cookies for session management, gate access, and so on.

One possible use for this is in conjunction with some kind of authentication when making requests to the key server. For example:
  1. Your customer logs into your website in a browser and their login shows that they are allowed to view content.
  2. Your application generates an authentication token, based on what is expected by the license server. Pass that value to the PSDK.
  3. The PSDK sets that value in the cookie header.
  4. When the PSDK makes a request to the key server to get a key to decrypt the content, that request contains the authentication value in the cookie header, so the key server knows the request is valid.
Create a cookieManager and add your cookies for the URIs to your cookieStore. For example:
CookieManager cookieManager=new CookieManager();
CookieHandler.setDefault(cookieManager); 
HttpCookie cookie=new HttpCookie("lang","fr");
cookie.setDomain("twitter.com"); 
cookie.setPath("/");
cookie.setVersion(0);
cookieManager.getCookieStore().add(newURI("http://twitter.com/"),cookie);
The PSDK queries this cookieManager at runtime and checks whether there are any cookies associated with the URL and uses those automatically.