protected function _initialize() {
        parent::_initialize(); // TODO: Change the autogenerated stub
        if (!session('?userID')) {
                trace('in here', 'debug');
                return json(['result' => false, 'msg' => '登录失效,请重新登录']);
        }
}public function doChangePsw() {
        trace('in dochangepsw', 'debug');
        $userID = input('post.userID');
        $oldPsw =input('post.oldPsw');
        $newPsw = input('post.newPsw');
        $userInfo = new UserInfo();
        $data = $userInfo->changeUserPsw($userID, $newPsw, $oldPsw);
        return json($data);
}本意是想在_initialize方法中判断session中userID是否存在,如果不存在直接返回重新登录提示,而不执行doChangePsw方法,而在实际执行中发现输出如下:
[ 2017-08-14T20:13:15+08:00 ] 127.0.0.1 127.0.0.1 POST /fanyi/index/dochangepsw.html
[ debug ] in here
[ debug ] in dochangepsw也就是_initialize()执行return json()后继续执行了doChangePsw()方法,请问这是什么原因。
另外如何实现我想要的功能,因为要在不同的方法中判断session中userID是否存在,所以不能把这个判断放在doChangePsw()方法中