2017  Kodetalk | Feedback | Privacy Policy | Terms | About
userimage

How to create a new cookie using java and send it as response

I need to create a cookie and send that cookie to client as response using Java code. How to do it?

userimage

Try below code to create a cookie and send it to client as response


Cookie cook = new Cookie(key, value);
// cook.setSecure(true);
// cook.setHttpOnly(true);
response.addCookie(cook);
Answer is