title: how to create a cookie and add to http response from inside my service layer?
body: <p>I am creating a custom authentication service in my spring mvc application:</p>
  
  <pre><code>@Service
  public class AuthenticationServiceImpl implements AuthenticationService {
  
     @Autowired
     UserService userService;
  
     @Override
     public void login(String email, String password) {
  
        boolean isValid = userService.isValidLogin(email, password);
  
        if(isValid) {
            // ??? create a session cookie and add to http response
        }
  
     }
  
  }
  </code></pre>
  
  <p>How can I create and add the cookie to the response?</p>