1.测试:Cookie和端口无关,和ip或域名有关
localhost:81 设置cookie : 请求发现请求头有cookie
localhost:82 不设置cookie : 请求发现请求头有cookie
192.168.199.225:82 不设置cookie : 请求发现请求头无cookie
localhost:81
@GetMapping("/health") public void health(HttpServletRequest request, HttpServletResponse response) { //设置1 response.addHeader("Set-Cookie","hello ytf 81"); //查看 Cookie[] cookies = request.getCookies(); if(cookies != null) for(Cookie c : cookies){ String name = c.getName();//获取Cookie名称 } }
localhost:82
@GetMapping("/health") public void health(HttpServletRequest request, HttpServletResponse response) { //设置1 // response.addHeader("Set-Cookie","hello 81"); //设置2 // Cookie cookie = new Cookie("jieguo","true"); // response.addCookie(cookie); //查看 Cookie[] cookies = request.getCookies(); if(cookies != null) for(Cookie c : cookies){ String name = c.getName();//获取Cookie名称 } }
192.168.199.225:82
2.同源策略
标签:cookies,request,cookie,关于,82,Cookie,response From: https://www.cnblogs.com/smileblogs/p/16936504.html