// AddCookie adds a cookie
516040
func AddCookie(ctx context.Context, cookie *http.Cookie, reclaim bool) {
	if reclaim {
		ctx.Request().AddCookie(cookie)
	}
	ctx.SetCookie(cookie)
}
1229088
func SetCookiePath(w http.ResponseWriter, name, value string, age int64, path string) {
	SetCookiePathWithFlags(w, name, value, age, path, false, false)
}
235465
func NewCookie(name, value string, options *CookieOpts) *http.Cookie {
	if options == nil {
		options = &CookieOpts{}
	}
	cookie := &http.Cookie{
		Name:     name,
		Value:    value,
		Path:     options.Path,
		Domain:   options.Domain,
		MaxAge:   options.MaxAge,
		Secure:   options.Secure,
		HttpOnly: options.HttpOnly,
	}
	if options.MaxAge > 0 {
		d := time.Duration(options.MaxAge) * time.Second
		cookie.Expires = time.Now().Add(d)
	} else if options.MaxAge < 0 {
		// Set it to the past to expire now.
		cookie.Expires = time.Unix(1, 0)
	}
	return cookie
}
1268526
func RemoveCookie(w http.ResponseWriter, r *http.Request, config Config) {
	c, err := r.Cookie(config.Cookie)
	if err != nil {
		return
	}

	c.Expires = CookieExpireDelete
	// MaxAge<0 means delete cookie now, equivalently 'Max-Age: 0'
	c.MaxAge = -1
	c.Value = ""
	c.Path = "/"
	c.Domain = formatCookieDomain(r.URL.Host, config.DisableSubdomainPersistence)
	AddCookie(w, r, c, config.AllowReclaim)

	if config.AllowReclaim {
		// delete request's cookie also, which is temporary available.
		r.Header.Set("Cookie", "")
	}
}
196289
func (F *Frisby) SetCookie(key, value string) *Frisby {
	if F.Req.Cookies == nil {
		F.Req.Cookies = make(map[string]string)
	}
	F.Req.Cookies[key] = value
	return F
}
1030754
func (fn CookieReaderFunc) ReadCookie(r io.Reader) (CookieJar, error) {
	return fn(r)
}
522517
func (b *HttpRequest) SetEnableCookie(enable bool) *HttpRequest {
	b.setting.EnableCookie = enable
	return b
}
310643
func AddCookieFasthttp(ctx *fasthttp.RequestCtx, cookie *fasthttp.Cookie) {
	ctx.Response.Header.SetCookie(cookie)
}
270436
func (h *RevelHeader) SetCookie(cookie string) {
	if h.Server != nil {
		h.Server.SetCookie(cookie)
	}
}
968276
func (s *ForwardedValues) SetCookies(v *CookiePreference) *ForwardedValues {
	s.Cookies = v
	return s
}
195089
func (state *UserState) SetUsernameCookie(w http.ResponseWriter, username string) error {
	if username == "" {
		return errors.New("Can't set cookie for empty username")
	}
	if !state.HasUser(username) {
		return errors.New("Can't store cookie for non-existing user")
	}
	// Create a cookie that lasts for a while ("timeout" seconds),
	// this is the equivalent of a session for a given username.
	cookie.SetSecureCookiePath(w, "user", username, state.cookieTime, "/", state.cookieSecret)
	return nil
}
440514
func (t *Tab) DeleteCookie(cookieName, url string) error {
	_, err := t.Page.DeleteCookie(cookieName, url)
	return err
}
1330081
func (rc *RequestConfig) SetCookie(cookies H) *RequestConfig {
	if len(cookies) > 0 {
		rc.Cookies = cookies
	}

	return rc
}
1068450
func AddCookie(w http.ResponseWriter, r *http.Request, cookie *http.Cookie, reclaim bool) {
	if reclaim {
		r.AddCookie(cookie)
	}
	http.SetCookie(w, cookie)
}
729466
func (i *Image) Cookie(u string) (string, error) {
	if i.client.Jar == nil {
		return "", nil
	}

	baseURL, err := url.Parse(u)
	if err != nil {
		return "", fmt.Errorf("Invalid URL: %s", err)
	}

	cookies := i.client.Jar.Cookies(baseURL)
	if len(cookies) == 0 {
		return "", nil
	}

	return cookies[0].String(), nil
}
200340
func (s *SuperAgent) AddCookies(cookies []*http.Cookie) *SuperAgent {
	s.Cookies = append(s.Cookies, cookies...)
	return s
}
342297
func (state *UserState) UsernameCookie(req *http.Request) (string, error) {
	username, ok := cookie.SecureCookie(req, "user", state.cookieSecret)
	if ok && (username != "") {
		return username, nil
	}
	return "", ErrCookieGetUsername

}