写入 Cookie
Cookie ckUserid = new Cookie("userid", Long.toString(bMember.getId()));
//ckUserid.setMaxAge(86400);
//ckUserid.setDomain("
www.mangocity.com");
//ckUserid.setPath("/MangoWeb;/TicketWeb;/CTIIWeb");
ckUserid.setPath("/");
response.addCookie(ckUserid);
读取 Cookie
// 从Cookie中读取,看用户是否已经登陆
Cookie[] cookies = request.getCookies();
if (cookies != null) {
for (int i = 0; i < cookies.length; i++) {
if ("userid".equals(cookies[i].getName())) {
if ((cookies[i].getValue() != null) && (!"".equals(cookies[i].getValue()))) {
id = Long.parseLong(cookies[i].getValue());
bmember = _MemberDao.retrieveWebMember(id);
}
}
}
}