public function getCode($uid) { if (empty($this->type)) { return false; } $this->cleanCode($uid); $code = FNbase::random(6); $data['uid'] = $uid; $data['status'] = "0"; $data['type'] = $this->type; $data['code'] = $code; $data['inserttime'] = FNbase::getTime(); $data['updatetime'] = FNbase::getTime(); $this->codelist->add($data); return $code . '-' . substr(md5($uid), 0, -7); }
protected function setSession($delete = false) { //$cache = FN::server('cache','session'); if ($delete) { //$cache->delete($this->session); $this->st->delete($this->session); } else { if (empty($this->user)) { return false; } if (empty($this->session)) { $this->session = FNbase::random(10); } //10位的随机性已经足够 $this->st->add(array('session' => $this->session, 'value' => FNbase::setEscape(json_encode($this->user), true), 'inserttime' => FNbase::getTime(), 'cachetime' => $this->cacheTime), true); //$cache->set($this->session,json_encode($this->user),false,$this->cacheTime); if (isset($this->user['password']) && $this->user['password']) { $this->login = '******'; } } $this->setCookie($delete); return true; }