Cookie ck=new Cookie("username","Dhaval Mehta");
response.addCookie(ck);
Cookie ck[]=request.getCookies();
for(int i=0;i<ck.length;i++)
{
out.print("<br>"+ck[i].getName()+"-"+ck[i].getValue());
}
HttpSession session = request.getSession();
session.setAttribute("username", "admin");
String s = session.getAttribute("username").toString();
out.println("Session ID: " + session.getId());
out.println("<br>Session Value: " + session.getAttribute("username"));
out.println("<br>Creation Time: " + new Date(session.getCreationTime()));
out.println("<br>Last Accessed Time: " + new Date(session.getLastAccessedTime()));