title: Creating a cookie inside a jax-rs endpoint
body: <p>I have a jax-rs endpoint. The purpose of the endpoint is to authorize a user. I need to login details inside a cookie. Below I have mentioned the related part of my code.</p>
  
  <pre><code>public Response authorize(@Context HttpServletRequest request) throws URISyntaxException {
       if (authnResult.isAuthenticated()) {
       //TODO create a cookie to maintain login state
                          Cookie authCookie = new Cookie(FrameworkConstants.COMMONAUTH_COOKIE, "test");
                          authCookie.setSecure(true);
                          authCookie.setHttpOnly(false);
                          authCookie.setMaxAge(5 * 60);
  }
  </code></pre>
  
  <hr>
  
  <p><strong>EDIT:</strong></p>
  
  <p>This is my first time when creating cookies. I followed some tutorials. In these tutorials it has added the created cookie to the response. But inside the endpoint I can't access the response. So how can I create the cookie? Please advice me.</p>
  
  <p>Updated code:</p>
  
  <pre><code>public Response authorize(@Context HttpServletRequest request) throws URISyntaxException {
      NewCookie cookie = new NewCookie("CookieName","CookieValue");
                      Response.ResponseBuilder builder = Response.ok("Cool Stuff");
                      builder.cookie(cookie);
                      Response response=builder.build();
      Cookie[] cookies = request.getCookies();
  }
  </code></pre>
  
  <p>what I need to know is how to access the newly created cookie.</p>