2015-07-13 15:27
浏览 29

CakePHP 3:如何正确检查用户是否已登录

In CakePHP 3, I found two ways to find if a user is logged in.

1st solution

        // Logged in

2nd solution

if (!is_null($this->request->session()->read(''))) {
    // Logged in

I think the first one is better because it's short and concise.

Is there a better way to verify if a user is logged in?

I'm not looking for speed necessarily. I want a clean and expressive way to write it.

  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

3条回答 默认 最新

相关推荐 更多相似问题