会话技术_Cookie_原理分析与会话技术_Cookie_细节1_发送多个Cookie
会话技术_Cookie_原理分析
Cookie实现原理
基于响应头set-Cookie和请求头cookie实现
会话技术_Cookie_细节1_发送多个Cookie
1.cookie的细节
1.一次可不可以发送多个cookie?
是可以的
可以创建多个Cookie对象,使用response调用多次addCookie方法发送cookie即可
package bd.xueqiang.Cookie; import javax.servlet.ServletException; import javax.servlet.annotation.WebServlet; import javax.servlet.http.Cookie; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.io.IOException; @WebServlet("/cookieDemo03") public class CookieDemo03 extends HttpServlet { /** * Cookis快速入门 * @param request * @param response * @throws ServletException * @throws IOException */ @Override protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { //1.创建Cookie对象 Cookie msg1 = new Cookie("msg", "hello"); Cookie msg2= new Cookie("fly", "yinuo"); //2.发送Cookis response.addCookie(msg1); response.addCookie(msg2); } @Override protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { this.doPost(request, response); } }
2.cookie在浏览器中保存多次时间?
3.cookie能不能中文?
4.cookie获取范围多大?