Get the App
SLTechnology News&Howtos  ›  Development  › 

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

Shulou Source: shulou.com Published: 2022-06-01 07:04:31 10月01日 Update

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!

Tags: Interfaces methods programs changes users learning services content that is situations servers development generation information parameters official ideas articles methods more Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Huawei Docker Shulou Information vpn NVidia