2017  Kodetalk | Feedback | Privacy Policy | Terms | About

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?


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);
Answer is