This piece of code I wrote to fulfill the purpose but its is not working it seems. Can you please help , something is wrong or missed here ?
HttpSession session = req.getSession(true);
final Cookie cookie = new Cookie("CPSESSIONID", session.getId());
//cookie.setPath("/");
cookie.setPath(";Path=/;HttpOnly;");
cookie.setSecure(true);
res.addCookie(cookie);