request.setCharacterEncoding("UTF-8");
String saklanan_cerez= "Cerez_kullanici";
Cookie killCookie = new Cookie(saklanan_cerez,null);
killCookie.setMaxAge(0);
killCookie.setPath("/");
response.addCookie(killCookie);
response.sendRedirect("index.jsp");
//Çerezi oluşturduk. Çerez_kullanici diye getirebileceğiz artık.
Cookie cookie = new Cookie ("Cerez_kullanici", URLEncoder.encode((adi+" "+soyadi),"UTF-8"));
//Çerezin süresini belirledik.
cookie.setMaxAge(10000);
//çerezi bilgisayarda oluşturuyoruz. kaydediyoruz yani.
response.addCookie(cookie);
request.setCharacterEncoding("UTF-8");
String saklanan_cerez= "Cerez_kullanici";
String bulunan_cerez_ad=null;
Cookie cookies [] = request.getCookies ();
for (int i = 0; i < cookies.length; i++){
if (cookies [i].getName().equals (saklanan_cerez)){
bulunan_cerez_ad = URLDecoder.decode(cookies[i].getValue(),"UTF-8");
break;
}
}
if(bulunan_cerez_ad==null)
response.sendRedirect("index.jsp");