In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly explains "how to make WeChat Mini Programs support cookie". The content in the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "how to make WeChat Mini Programs support cookie".
Intro
Wechat's native wx.request network request interface does not support traditional Cookie, but sometimes our existing back-end interfaces do rely on Cookie (such as server user login status). This library can use one line of code to implement the Cookie mechanism for your Mini Program to ensure that the cookie-based service session will not expire and share the session mechanism with the web.
Installnpm install weapp-cookie-save# copies the npm package to the vendor folder to avoid the possibility that Mini Program may not be able to find the file (tips: no need for this step using frameworks such as wepy/mpvue) cp-rf. / node_modules/. / vendor/ copy the code Usage
You can introduce a single line of code in the root directory of Mini Program by introducing it.
/ / app.jsimport'. / vendor/weapp-cookie/index'// tips: using wepy/mpvue, you can directly introduce the weapp-cookie module / / import 'weapp-cookie'App ({onLaunch: function () {} / /.}) in the entry js to copy the code.
The original wx.request call mode remains unchanged. After the introduction, weapp-cookie will automatically proxy wx.request interface access in the underlying layer to support cookie storage and sending.
/ / pages/home/index.jsPage ({onLoad: function () {wx.request ({url: 'https://example.com/login', data: {username:' admin', password: '123456'} Success: function (res) {/ * * after the API is called successfully, weapp-cookie will automatically save all Cookie sent by the backend (such as SessionID) * and include it in all subsequent requests. To ensure that the cookie-based server session mechanism will not fail, * implement the shared session mechanism with the web side (no need to manually maintain the 3rd_session_key) * /}) copy the code thank you for reading, this is the content of "how to make WeChat Mini Programs support cookie", after the study of this article I believe you have a deeper understanding of how to make WeChat Mini Programs support cookie, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.