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

The solution to the PHPSESSID change of Mini Program's request API interface

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

Share

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

This article mainly explains the "Mini Program request API interface PHPSESSID change solution", the article explains the content is simple and clear, easy to learn and understand, now please follow the editor's train of thought slowly in depth, together to study and learn "Mini Program request API interface PHPSESSID change solution" bar!

Developed by WeChat Mini Programs, the method of requesting server API uses the wx.request () method provided officially by Wechat.

In development, it is found that each request generates a separate PHPSESSID.

After searching, we know that this is caused by wx.request (). This does not happen if you use the browser request directly.

The solution is as follows:

Obtain the user's session_key and open_id through the login API. Set the session information as follows:

$3rd_session = md5 (session_key. $open_id) $_ SESSION [$3rd_session] = session_key. '|'. $open_id

The server generates the session_id for this user, and the interface returns 3rd_session and session_id.

In other interface requests, set the value of cookie in header: session_id:

Header = header | | {'content-type':' application/x-www-form-urlencoded;', 'Cookie':' PHPSESSID=session_ id'}

And put the parameter session=3rd_session in the API. In this case, the server gets the same session_id and gets the user's openid from $_ SESSION according to 3rd_session.

Thank you for your reading, the above is the content of "Mini Program requests the solution of API interface PHPSESSID change". After the study of this article, I believe you have a deeper understanding of the problem of Mini Program requesting API interface PHPSESSID change, 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.

Share To

Development

Wechat

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

12
Report