code: func (s *SecureCookie) Encode(name string, value interface{}) (string, error) {
  	if s.err != nil {
  		return "", s.err
  	}
  	if s.hashKey == nil {
  		s.err = errHashKeyNotSet
  		return "", s.err
  	}
  	var err error
  	var b []byte
  	// 1. Serialize.
  	if b, err = s.sz.Serialize(value); err != nil {
  		return "", cookieError{cause: err, typ: usageError}
  	}
  	// 2. Encrypt (optional).
  	if s.block != nil {
  		if b, err = encrypt(s.block, b); err != nil {
  			return "", cookieError{cause: err, typ: usageError}
  		}
  	}
  	b = encode(b)
  	// 3. Create MAC for "name|date|value". Extra pipe to be used later.
  	b = []byte(fmt.Sprintf("%s|%d|%s|", name, s.timestamp(), b))
  	mac := createMac(hmac.New(s.hashFunc, s.hashKey), b[:len(b)-1])
  	// Append mac, remove name.
  	b = append(b, mac...)[len(name)+1:]
  	// 4. Encode to base64.
  	b = encode(b)
  	// 5. Check length.
  	if s.maxLength != 0 && len(b) > s.maxLength {
  		return "", errEncodedValueTooLong
  	}
  	// Done.
  	return string(b), nil
  }
docs: // Encode encodes a cookie value.
  //
  // It serializes, optionally encrypts, signs with a message authentication code,
  // and finally encodes the value.
  //
  // The name argument is the cookie name. It is stored with the encoded value.
  // The value argument is the value to be encoded. It can be any value that can
  // be encoded using the currently selected serializer; see SetSerializer().
  //
  // It is the client's responsibility to ensure that value, when encoded using
  // the current serialization/encryption settings on s and then base64-encoded,
  // is shorter than the maximum permissible length.