Why can't I use {code...} in the same session of two controllers in one module during public platform development ...} {code ...} why is one session unavailable in two controllers in one module during public platform development?
// Obtain basic user information through webpage authorization public function webUsers () {$ token = session ('Token'); $ wechatAuth = new WechatAuth ($ this-> appId, $ this-> appSecret, $ token); // $ wechatAuth = $ this-> wechatAuth; if ($ _ GET ['iscode']) {$ url = "http://hdzs.zhed.com/index.php/Activity/index "; $ result = $ wechatAuth-> getRequestCodeurl ($ url); header ("Location: {$ result}");} else if ($ _ GET ['code']) {header ('content-type: text/html; charset = UTF-8 '); $ users = $ wechatAuth-> getAccessToken ('code ', $ _ GET ['code']); // confused statement $ User = M ("User"); // instantiate the user object $ openid = $ users ['openid']; session ('openid', "$ openid"); // save your openid to the session
Public function users ($ wechat, $ data) {$ openid = $ data ['fromusername']; // session (null); // session ('openid ', "$ openid"); // $ wechatAuth = $ this-> wechatAuth; // instantiate $ wechatAuth object // $ user = $ wechatAuth-> UserInfo ($ openid ); $ text = "your username is :". session ('openid'); $ this-> logger ("Send user message ". $ text); // $ wechat-> replyText ($ text );}"
Reply content:
Why is one session unavailable in two controllers in one module during public platform development?
// Obtain basic user information through webpage authorization public function webUsers () {$ token = session ('Token'); $ wechatAuth = new WechatAuth ($ this-> appId, $ this-> appSecret, $ token); // $ wechatAuth = $ this-> wechatAuth; if ($ _ GET ['iscode']) {$ url = "http://hdzs.zhed.com/index.php/Activity/index "; $ result = $ wechatAuth-> getRequestCodeurl ($ url); header ("Location: {$ result}");} else if ($ _ GET ['code']) {header ('content-type: text/html; charset = UTF-8 '); $ users = $ wechatAuth-> getAccessToken ('code ', $ _ GET ['code']); // confused statement $ User = M ("User"); // instantiate the user object $ openid = $ users ['openid']; session ('openid', "$ openid"); // save your openid to the session
Public function users ($ wechat, $ data) {$ openid = $ data ['fromusername']; // session (null); // session ('openid ', "$ openid"); // $ wechatAuth = $ this-> wechatAuth; // instantiate $ wechatAuth object // $ user = $ wechatAuth-> UserInfo ($ openid ); $ text = "your username is :". session ('openid'); $ this-> logger ("Send user message ". $ text); // $ wechat-> replyText ($ text );}"
session(null);
Session (null); // The session has been cleared. Of course, the following cannot be obtained.