当前位置:网站首页>Wechat applet request requests to carry cookies to verify whether it has logged in
Wechat applet request requests to carry cookies to verify whether it has logged in
2022-07-25 07:04:00 【Wind chaser?】
Wechat applet settings cookie
WeChat pair wx.request This API Made modifications , The request initiated by the applet does not directly request our background server , Instead, it is first sent to our background server through wechat server , Since all requests are sent to our server through wechat server , Then our server will not be able to identify the originator of the request . therefore ,cookie It cannot be used in the background development of wechat applet
Because the applet does not support cookie, So you can't use the background language directly session:
1. Read after the login request is successful The return value of , header Of cookie, And store locally
// After the login request comes back , Read res Of header Of cookie
//cookie Is a unique identifier
wx.setStorageSync("cookie", res.header["Set-Cookie"])
Set at the next request header, And write cookie
// establish header
var header;
header = {
'content-type': 'application/json',
'cookie':wx.getStorageSync("cookie")// Read cookie
};
// For the request , Generally, the outer layer has a package , Then put it in the public class
wx.request({
url: URL,
method: method,
header: header,// Pass on the requested header in
data: datas,
success(res) {
// Request successful processing
}
)}
In this way, the server can receive the carried cookies
边栏推荐
- A little consideration of strategic mode
- JS data type judgment - Case 6 delicate and elegant judgment of data type
- EFCore高级Saas系统下单DbContext如何支持不同数据库的迁移
- Mathematics Olympiad vs Informatics Olympiad (July 19, 2022)
- 【每日一题】1184. 公交站间的距离
- Electronic Association C language level 2 60, integer parity sort (real question in June 2021)
- How can dbcontext support the migration of different databases in efcore advanced SaaS system
- Kyligence Li Dong: from the data lake to the index middle stage, improve the ROI of data analysis
- 【每日一题】剑指 Offer II 115. 重建序列
- Decrypting numpy is a key difficulty in solving the gradient
猜你喜欢

【transformer】DeiT

Qt实战案例(53)——利用QDrag实现拖拽拼图功能

OpenAtom XuperChain 开源双周报 |2022.7.11-2022.7.22

Thread 类的基本用法

共模电感听过很多次,但是什么原理你们真的懂吗?

Easy gene chip SEQ analysis method: practical workflow and advanced applications

【愚公系列】2022年7月 Go教学课程 015-运算符之赋值运算符和关系运算符
![[Yugong series] July 2022 go teaching course 015 assignment operators and relational operators of operators](/img/37/4a892b96bec8cfa7efe38046c5dfc9.png)
[Yugong series] July 2022 go teaching course 015 assignment operators and relational operators of operators

Recycleview realizes horizontal sliding of overlapping items

MySQL remote login
随机推荐
【电脑讲解】去电脑维修店修电脑需要注意什么?
Addition, deletion, modification and query of DOM elements
The income of bank financial management is getting lower and lower. Now which financial products have high income?
在C# WinForms应用程序中安装,配置和使用MetroFramework
Cointelegraph撰文:依托最大的DAO USDD成为最可靠的稳定币
CodeForces 1417B Two Arrays
error: redefinition of
GIS实战应用案例100篇(十七)-基于DEM制作三维地图
[cann training camp] play with the one-stop plan of cann target detection and recognition - learning notes 1 (initial experience)
The ultimate difference between MVC and three-tier architecture
Robot engineering - teaching quality - how to judge
YOLOv7模型推理和训练自己的数据集
分层强化学习综述:Hierarchical reinforcement learning: A comprehensive survey
Expandablelistview nested GridView display incomplete problem
The relationship between Informatics, mathematics and Mathematical Olympiad (July 19, 2022) C
Create a new STM32 project and configure it - based on registers
睡眠不足有哪些危害?
Thread 类的基本用法
Shell run command
Clear wechat applet and wechat H5 cache