search

Home  >  Q&A  >  body text

angular.js - How does angular maintain openid status during official account development?

I encountered a problem with persistent openid when using the WeChat public account. In the current project, the server side is used to obtain the openid and then store it in the session and then return to the front end. There is a public base.js file in angular to asynchronously obtain the openid and Write to localStorage for other pages to call.

The current problem is that after entering the page for the first time to obtain the openid, it can be used normally in the page, and it can also be obtained when jumping between pages. However, once WeChat is closed from the background and then entered and clicked on the official account menu, the openid will be obtained again. , and then redirected to the page defined in redirect_url, causing the user to be unable to enter the corresponding menu normally. I don’t know whether Angular’s ​​method of obtaining openid is wrong or the server’s approach is wrong. I hope you can give me some advice!

ringa_leeringa_lee2724 days ago1315

reply all(2)I'll reply

  • 滿天的星座

    滿天的星座2017-07-04 13:46:38

    The description of this problem is not very clear. If you want to obtain an openid, you must authorize it through WeChat's web page. First get the authorization code, and then get the openid. So openid tries to cache it.

    reply
    0
  • 怪我咯

    怪我咯2017-07-04 13:46:38

    It stands to reason that the program runs in the browser provided by WeChat. When WeChat is launched, the program must also be closed. When entering here, go to the server again to get it, everything is new. In fact, the openId can be saved in the service, and there is no need to save it in local storage.

    I don’t understand what you mean, please sort it out again.

    reply
    0
  • Cancelreply