Small WeChat official account project does not use easywechat and other composer packages, and pure source laravel development.
When obtaining the openid, judge whether the URL has a code, and if it does not exist, the
header("location:xxx")Go to exchange the code, and curl takes the openid, but every time you get it, you can save the session directly. However, when you request other pages, the data in the session does not exist. It is suspected that the redirection problem may lead to different sessions, and you don’t know how to deal with it?
Sessions are by site. The same site is OK, you need to see if your site is different (write and take out the site), cookie configuration is not a problem. Normal is not a problem, find the reason, really can not use redis save or directly save mysql. And why use session to save openid? Shouldn’t it be saved as user information? Because openid will not change for the same official account, do you not have your own user system?