title: How to set and check cookies wih JAX-RS?
body: <p>I am a noobie with RESTful API and I am trying to build a Login service in which I provide an email and password and if the validation is successful - to store a cookie.
  In addition, how do I check the cookie(if stored)?</p>
  
  <p>How can this be achieved?</p>
  
  <pre><code>@Path("/login")
  @POST
  @Produces(MediaType.APPLICATION_JSON)
  @Consumes({MediaType.APPLICATION_FORM_URLENCODED, MediaType.APPLICATION_JSON})
  public Response Login(final String i_LoginDetails) throws JSONException {
      final JSONObject obj = new JSONObject(i_LoginDetails);
      try {
          if (isValidUser(obj.getString("email"), obj.getString("password"))) {
              // Set a cookie
          } else {
              // return error invalid-credentials message
          }
      } catch (Exception e) {
          e.printStackTrace();
      }
      return Response.ok("TEST").build();
  }
  </code></pre>
  
  <p>And how do I check the cookie(if set)?</p>