I'm redirecting the user to some URL and I want to send a cookie with it:
Cookie cookie = new Cookie("CADASTROADM", "someValue");
cookie.setPath("/");
cookie.setMaxAge(129600); //With it or without, makes no difference.
URL urlToRedirect = new URL(pageToRedirect);
cookie.setDomain(urlToRedirect.getHost());//With it or without, makes no difference.
response.addCookie(cookie);
response.sendRedirect(pageToRedirect);
However, when he's redirected to the page, the cookie is not there. I cannot use requestDispatcher.forward() because I'm redirecting the user to an absolute page.
Is it possible? What am I doing wrong?