To get a cookie that has been stored on a client, you first collect all the
available cookies using the getCookies
method. Then, you look for the name of the cookie you want in the returned
array of cookies. You deploy the getName
method to find the
cookie; once you find the cookie, you deploy the getValue
method.
Cookies [] cookies = request.getCookies(); for (int i = 0; i < cookies.length; ++i) { if("votes".equals(cookies[i].getName())) { ... cookies[i].getValue() ... }}