Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What if Mini Program can't trigger SESSION?

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces the relevant knowledge of "Mini Program can not trigger SESSION". The editor shows you the operation process through an actual case. The operation method is simple, fast and practical. I hope this "Mini Program can not trigger SESSION how to solve" article can help you solve the problem.

First, find the address of the first network request, return the server to set-cookie and store it as a global variable

Wx.request ({. Success: function (res) {console.log (res.header); / / set-cookie:PHPSESSID=ic4vj84aaavqgb800k82etisu0; path=/; domain=.fengkui.net / / Log in successfully, get the first sessionid, store it / / Note: Set-Cookie (debug all lowercase in developer tools) (remote debugging and online initials uppercase) wx.setStorageSync ("sessionid", res.header ["Set-Cookie"]);}})

2. When requesting, put the sessionid into the header header of request and transfer it to the server, and the server can obtain it directly in cookie.

Wx.request ({. Header: {'content-type':' application/json', / / default 'cookie': wx.getStorageSync ("sessionid") / / read sessionid as cookie is passed into the background to use PHPSESSID as session_id}, success: function (res) {console.log (res)}})

Third, the backend acquires the PHPSESSID in cookie and uses PHPSESSID as a session_id

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.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report