ThinkPHP判断会员登录控制器

0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
<?php
namespace Home\Controller;
use Think\Controller;
 
class CommonController extends Controller {
  public $user;
  public function _initialize(){
    if (!$user = $this->checkSession()) {
      $action = strtolower(ACTION_NAME);
      if (!in_array($action, array('login', 'checklogin'))) {
        redirect('/User/Login/');
      }
    }
    $this->user = $user;
  }
  function checkSession() {
    return isset($_SESSION['user']) ? $_SESSION['user']:false;
  }
}

发表评论

您的邮箱不会公开,当您的评论有新的回复时,会通过您填写的邮箱向您发送评论内容。 必填字段 *

为何看不到我发布的评论?

正在提交, 请稍候...