/** * Cookie Hash * @return string */ public function cookieHash(AuthedUserInterface $user) { $salt = $this->config()->get("auth")->get("cookie_hash", "8)pu1j[Juogi5263N6sS5s+fE5V/kw"); return sha1($user->ID() . $salt . Session::ID()); }
/** * Store User * @param AuthedUserInterface * @return BOOL */ public function storeUser(AuthedUserInterface $user) { $this->_user = $user; $encryptedData = Encryption::encrypt(implode("|", [$user->ID(), $this->cookieHash($user), json_encode($user->userInfo())])); $cookieData = base64_encode(Encryption::encrypt(implode("|", [$user->username(), $encryptedData]))); //Set Cookie; if (!Cookie::set(self::LOGIN_COOKIE_KEY, $cookieData, Cookie::ONE_DAY, WORKING_DIR, null, true)) { \pre_r("Failed to set cookie"); } return true; }