title: Cookies turned off with Java URLConnection
body: <p>I am trying to make a request to a webpage that requires cookies.  I'm using HTTPUrlConnection, but the response always comes back saying</p>
  
  <pre><code>&lt;div class="body"&gt;&lt;p&gt;Your browser's cookie functionality is turned off. Please turn it on.
  </code></pre>
  
  <p>How can I make the request such that the queried server thinks I have cookies turned on.  My code goes something like this.</p>
  
  <pre><code>private String readPage(String page) throws MalformedURLException {
      try {
          URL url = new URL(page);
          HttpURLConnection uc = (HttpURLConnection) url.openConnection();
          uc.connect();
  
          InputStream in = uc.getInputStream();
          int v;
          while( (v = in.read()) != -1){
              sb.append((char)v);
          }
          in.close();
          uc.disconnect();
      } catch (IOException e){
          e.printStackTrace();
      }
      return sb.toString();
  }
  </code></pre>