二月九日

作者:

文章目录

1)创建Cookie:

Cookie cookie = new Cookie(String cookieName,String cookieValue);

示例:

Cookie cookie = new Cookie(“username”,”zhangsan”);

设置Cookie在客户端的持久化时间:cookie.setMaxAge(10*60);

3)设置Cookie的携带路径:

cookie.setPath(“/”);

response.addCookie(Cookie cookie);

HttpSession session = request.getSession();

session.setAttribute(String name,Object obj);

session.getAttribute(String name);

session.removeAttribute(String name);

评论

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

站内搜索