/ Published in: Java

Simple snippet on how to get/set a cookie
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
// retrieve cookies Cookie[] cookies = request.getCookies(); for(int i=0; i < cookies.length; i++) { Cookie c = cookies[i]; if (c.getName().equals("theCookieImLookingFor")) { } } // ... // set a new cookie Cookie myCookie = new Cookie("name", "value"); response.addCookie(myCookie);
URL: http://www.commentcamarche.net/servlets/servcookie.php3
Comments
