/** * * 访问前判断是否登录 */ public function _initialize() { parent::_initialize(); $user = session('user'); if ($user == null) { $this->error("请重新登录!", U('Shop/Index/login')); } }
protected function _initialize() { parent::_initialize(); if (!session('?shoppingcart')) { session("shoppingcart", array()); } $this->cart = session("shoppingcart"); }
protected function _initialize() { parent::_initialize(); $showStartPage = true; $last_entry_time = cookie("last_entry_time"); if (empty($last_entry_time)) { //一小时过期 cookie("last_entry_time", time(), 3600); $last_entry_time = time(); } elseif (time() - $last_entry_time < 20 * 60) { $showStartPage = false; } else { //一小时过期 cookie("last_entry_time", time(), 3600); } $this->assign("showstartpage", $showStartPage); }
protected function _initialize() { parent::_initialize(); }