cookie

目录

编码和解码

前端
cookie.save("user", window.encodeURI(JSON.stringify(res.data))
const user = JSON.parse(window.decodeURI(cookie.load("user") || "{}"));

java
string = URLEncoder.encode(string , "UTF-8"); //编码
string = URLDecoder.decode(string, "UTF-8"); // 解码

react操作coockie

yarn add react-cookies -D
import cookie from 'react-cookies'

cookie.save('userId', "123"{
      path: '/',
      expires,
      maxAge: 1000, // maxAge 单位秒
      domain: 'https://play.bukinoshita.io',
      secure: true
      httpOnly: true
    })


cookie.load('userId')


cookie.remove('userId')

https://www.npmjs.com/package/react-cookies

上一篇:Vue插件


下一篇:SharePoint Online 创建门户网站系列之导航