public function setRememberCookie($iId = null, $sPassword = null, $sEmail = null)
    {
        //  Is remember me functionality enabled?
        $oConfig = Factory::service('Config');
        $oConfig->load('auth/auth');

        if (!$oConfig->item('authEnableRememberMe')) {
            return false;
        }

        // --------------------------------------------------------------------------

        if (empty($iId) || empty($sPassword) || empty($sEmail)) {

            if (!activeUser('id') || !activeUser('password') || !activeUser('email')) {

                return false;

            } else {
                $iId       = $this->activeUser('id');
                $sPassword = $this->activeUser('password');
                $sEmail    = $this->activeUser('email');
            }
        }

        // --------------------------------------------------------------------------

        //  Generate a code to remember the user by and save it to the DB
        $oEncrypt = Factory::service('Encrypt');
        $sSalt    = $oEncrypt->encode(sha1($iId . $sPassword . $sEmail . APP_PRIVATE_KEY . time()));

        $oDb = Factory::service('Database');
        $oDb->set('remember_code', $sSalt);
        $oDb->where('id', $iId);
        $oDb->update($this->table);

        // --------------------------------------------------------------------------

        //  Set the cookie
        set_cookie([
            'name'   => $this->sRememberCookie,
            'value'  => $sEmail . '|' . $sSalt,
            'expire' => 1209600, //   2 weeks
        ]);

        // --------------------------------------------------------------------------

        //  Update the flag
        $this->bIsRemembered = true;

        return true;
    }