Mini Program ---- Session

When I was working on a small program, I found that the session was invalid. Finally, Baidu’s small program had a problem with the session and learned that the small program requested a session at a time. In this case, when we involved login operations, there would be problems, at least not so convenient, and finally got The solution, come up to share a wave of
java:
Insert picture description here

①: in app.js
Insert picture description here

②: In the js that clicks to send the verification code request :
Insert picture description here
write the sessionid into app.js
Insert picture description here

③: When we make a request for verification code judgment:
Insert picture description here

Insert picture description here

Then we can get the session normally,

For example, during the login operation, click login, send a request, return a json data (sessionid in the json data), write the sessionid into app.js,,,, when we need to use this session operation, we Just call this sessionid, write header: header in the header of the request, and then the backend can operate through getSession().getAttribute

Guess you like

Origin blog.csdn.net/qq_38637558/article/details/83899641