티스토리 뷰
String[] cookie_list = {"clist1", "clist2", "clist3", "clist4", "clist5"}; // HashMap에 들어갈 key name
Cookie[] cookies = request.getCookies(); // 현재 있는 쿠키를 받아서
HashMap map = new HashMap();
boolean check = false; // 중복확인체크for(int i=0; i map.put(cookie_list[i], cookies[i].getValue()); // map에 대입
}
if(!map.containsValue(request.getParameter("idx"))){ // 중복숫자 x
for(int i=map.size()-1; i>0 && i<=cookie_list.length; i--){ // 마지막부터
if(i!=cookies.length){ // 맨끝은 제외
map.remove(cookie_list[i]); // 한칸씩 뒤로
map.put(cookie_list[i], (String)map.get(cookie_list[i-1])); // 이동
}
}
} else{ // 중복숫자 o
for(int i=map.size()-1; i>0 && i<=cookie_list.length; i--){ // 마지막부터
if(i!=cookies.length){ // 맨끝은 제외
if(((String)map.get(cookie_list[i])).equals(request.getParameter("idx"))){ // 중복숫자체크
check = true; // 확인 후
}
if(check){ // 중복이 발견 된 곳부터
map.remove(cookie_list[i]); // 한칸씩 뒤로
map.put(cookie_list[i], (String)map.get(cookie_list[i-1])); // 이동
}
}
}
}
map.put(cookie_list[0], request.getParameter("idx")); // 맨 앞에 현재 본 상품 삽입
for(int i=0; i Cookie cookie = new Cookie(cookie_list[i], (String)map.get(cookie_list[i])); // 쿠키굽기
response.addCookie(cookie);
}
for(int i=0; i out.println(cookies[i].getName() + ": " + cookies[i].getValue()+"
"); // 쿠키확인
}
Cookie[] cookies = request.getCookies(); // 현재 있는 쿠키를 받아서
HashMap map = new HashMap();
boolean check = false; // 중복확인체크for(int i=0; i map.put(cookie_list[i], cookies[i].getValue()); // map에 대입
}
if(!map.containsValue(request.getParameter("idx"))){ // 중복숫자 x
for(int i=map.size()-1; i>0 && i<=cookie_list.length; i--){ // 마지막부터
if(i!=cookies.length){ // 맨끝은 제외
map.remove(cookie_list[i]); // 한칸씩 뒤로
map.put(cookie_list[i], (String)map.get(cookie_list[i-1])); // 이동
}
}
} else{ // 중복숫자 o
for(int i=map.size()-1; i>0 && i<=cookie_list.length; i--){ // 마지막부터
if(i!=cookies.length){ // 맨끝은 제외
if(((String)map.get(cookie_list[i])).equals(request.getParameter("idx"))){ // 중복숫자체크
check = true; // 확인 후
}
if(check){ // 중복이 발견 된 곳부터
map.remove(cookie_list[i]); // 한칸씩 뒤로
map.put(cookie_list[i], (String)map.get(cookie_list[i-1])); // 이동
}
}
}
}
map.put(cookie_list[0], request.getParameter("idx")); // 맨 앞에 현재 본 상품 삽입
for(int i=0; i Cookie cookie = new Cookie(cookie_list[i], (String)map.get(cookie_list[i])); // 쿠키굽기
response.addCookie(cookie);
}
for(int i=0; i out.println(cookies[i].getName() + ": " + cookies[i].getValue()+"
"); // 쿠키확인
}
'Network > PHP' 카테고리의 다른 글
PHP를 이용한 다중 연결 소켓 통신 (0) | 2008.02.13 |
---|---|
PHP 함수 (0) | 2006.08.18 |
[PHPSchool] 오늘 본 상품 출력 (0) | 2006.08.03 |
PHP를 이용한 개발 기간의 단축 (0) | 2006.06.04 |
[PHPSchool] 일본어 송신 관련 (0) | 2006.06.03 |
공지사항
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
TAG
- Life News
- network
- Network Inspector
- console
- WDB
- Assembly
- diary
- Military
- cartoon
- 막장로그
- Reverse Engineering
- 프리랜서로 살아남는 법
- 짤방 및 아이콘
- BadCode
- Battle
- Linux
- 3D Engine
- Web Programming
- USB Lecture
- wallpaper
- Tech News
- 나비효과
- win32
- C#
- Embedded System
- Mabinogi
- Information Processor
- medical
- humor
- 야마꼬툰
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | |||
5 | 6 | 7 | 8 | 9 | 10 | 11 |
12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 | 21 | 22 | 23 | 24 | 25 |
26 | 27 | 28 | 29 | 30 | 31 |
글 보관함