public function encryptSecureCookie($value, $expire, $userid = null)
    {
        $expire = (strcmp(strtolower($expire), 'never') === 0 ? time() + 60 * 60 * 24 * 6000 : $expire);

        if (is_null($userid))
            $userid = (string)$this->RequestContext->getUserRef();

        $key = hash_hmac('sha1', $userid.$expire, $this->key);
        $encrValue = base64_encode($this->encrypt($value, md5($expire)));

        if ($this->includeSSLKey == true && ($sslKey = $this->Request->getServerAttribute('SSL_SESSION_ID')))
            $verifyKey = hash_hmac('sha1', $userid . $expire . $value . $sslKey, $key);
        else
            $verifyKey = hash_hmac('sha1', $userid . $expire . $value, $key);

        $result = array($userid, $expire, $encrValue, $verifyKey);
        return(implode('|', $result));
    }