文章目录
前言
提示:这里可以添加本文要记录的大概内容:
提示:以下是本篇文章正文内容,下面案例可供参考
一、Cookie
1:Cookie是什么?
Cookie:是浏览器在本地持久化存储数据的一种机制。
2:Cookie的数据从哪来?
Cookie的数据是浏览器返回给浏览器的。
3:Cookie的数据长啥样 ?
Cookie中是键值对中的数据,并且这些键值对中的数据都是程序员自定义的。
4:Cookie的作用
5:Cookie到哪里去?
Cookie中的内容会在下次访问该网站的时候,自动被带到http请求中。
6:Cookie怎么存的?
浏览器按照不同的"域名"分别存储cookie.域名和域名之间的cookie是不同的。
Cookie是存储在硬盘上。Cookie往往会有超时时间。
二.代码
我在springboot中写的代码
package com.example.demo.demos.web;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.Mapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.servlet.http.Cookie;
import