public function asd_gets(){
$session_name = Session::get('name');
$session_username = Session::get('username');
return $session_username;
}
public function login()
{
if (request()->isPost()) {
$name = Request::instance()->post('name');
$pwd = Request::instance()->post('pwd');
$res = Db::table('usertable')->where('user', $name)->find();
if ($res) {
if ($res['pwd'] == $pwd && $res['user'] == $name) {
//开启session
$username = $res['username'];
$session_name = Session::set('name', $name);
$session_username = Session::set('username',$username);
asd_gets();
return $this->success('登录成功', 'http://leisureshop.cn/index.php/index/index/tindex', -1, 2);
} else {
return $this->error('用户或密码错误不存在', "http://leisureshop.cn/index.php/index/login/login", -1, 2);
}
} else {
return $this->error('用户不存在', "http://leisureshop.cn/index.php/index/login/login");
}
}
return $this->fetch();
}
上面是控制器 index.php
下面是控制器 goods.php
namespace app\index\controller;
use think\Controller;
use thinK\Db;
use think\Request;
class Goods extends Controller
{
public function gouwuche()
{
$test = Controller('index/Index');
echo $test->asd_gets();
return;
}
}
然后我在goods.php这个控制器上调用控制器index.php想通过asd_gets()方法把当前登录的session传到goods.php这个控制器上。但是运行到
asd_gets();就报错 调用未定义的函数appindexcontrollersessionu gets()。
请问如果我想调用的asd_gets()应该怎么办。