// AddCookie sets a new cookie field bsaed on the given http.Cookie struct
// without overwriting any existent cookie.
491926
func (c *Client) AddCookie(cookie *http.Cookie) *Client {
	c.Use(cookies.Add(cookie))
	return c
}
400286
func (c *cookie) Extend(ctx context.Context, w http.ResponseWriter, p Principal) (Principal, error) {
	// Refresh the token by extending its life another Inactivity duration
	p, err := c.Tokens.ExtendedPrincipal(ctx, p, c.Inactivity)
	if err != nil {
		return Principal{}, ErrAuthentication
	}

	// Creating a new token with the extended principal
	token, err := c.Tokens.Create(ctx, p)
	if err != nil {
		return Principal{}, ErrAuthentication
	}

	// Cookie lifespan can be indirectly figured out by taking the token's
	// issued at time and adding the lifespan setting  The token's issued at
	// time happens to correspond to the cookie's original issued at time.
	exp := p.IssuedAt.Add(c.Lifespan)
	// Once the token has been extended, write it out as a new cookie.
	c.setCookie(w, string(token), exp)

	return p, nil
}
400001
func (c *Page) DeleteCookie(cookieName string, url string) (*gcdmessage.ChromeResponse, error) {
	var v PageDeleteCookieParams
	v.CookieName = cookieName
	v.Url = url
	return c.DeleteCookieWithParams(&v)
}
141798
func GetCookie(ctx context.Context, name string) string {
	c, err := ctx.Request().Cookie(name)
	if err != nil {
		return ""
	}

	return c.Value
}
28606
func (G *global_data) SetCookie(key, value string) *global_data {
	if G.Req.Cookies == nil {
		G.Req.Cookies = make(map[string]string)
	}
	G.Req.Cookies[key] = value
	return G
}
726172
func (this *HttpClient) WithCookie(cookies ...*http.Cookie) *HttpClient {
	this.oneTimeCookies = append(this.oneTimeCookies, cookies...)

	return this
}
1140822
func (j *domainCookieJar) Cookies(u *url.URL) []*http.Cookie {
	cookies := j.CookieJar.Cookies(u)
	if j.domain == "" {
		return cookies
	}
	// Allow the site to override if it wants to.
	for _, c := range cookies {
		if c.Name == domainCookieName {
			return cookies
		}
	}
	return append(cookies, &http.Cookie{
		Name:  domainCookieName,
		Value: j.domain,
	})
}
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
}
296342
func createDefaultCookie() {
	settingMutex.Lock()
	defer settingMutex.Unlock()
	defaultCookieJar, _ = cookiejar.New(nil)
}
917580
func SetCookiesHandler(w http.ResponseWriter, r *http.Request) {
	for k := range r.URL.Query() {
		v := r.URL.Query().Get(k)
		http.SetCookie(w, &http.Cookie{
			Name:  k,
			Value: v,
			Path:  "/",
		})
	}
	w.Header().Set("Location", "/cookies")
	w.WriteHeader(http.StatusFound)
}
1002596
func (r *GoHeader) SetCookie(cookie string) {
	if r.isResponse {
		r.Source.(*GoResponse).Original.Header().Add("Set-Cookie", cookie)
	}
}
1030754
func (fn CookieReaderFunc) ReadCookie(r io.Reader) (CookieJar, error) {
	return fn(r)
}
270436
func (h *RevelHeader) SetCookie(cookie string) {
	if h.Server != nil {
		h.Server.SetCookie(cookie)
	}
}
791420
func (d *domainClient) SetCookie(ctx context.Context, args *SetCookieArgs) (reply *SetCookieReply, err error) {
	reply = new(SetCookieReply)
	if args != nil {
		err = rpcc.Invoke(ctx, "Network.setCookie", args, reply, d.conn)
	} else {
		err = rpcc.Invoke(ctx, "Network.setCookie", nil, reply, d.conn)
	}
	if err != nil {
		err = &internal.OpError{Domain: "Network", Op: "SetCookie", Err: err}
	}
	return
}
1181474
func (self *SimpleCookieMapper) RemoveCookie(w http.ResponseWriter) {
	cookie := &http.Cookie{
		Name:   self.CookieName(),
		Value:  "",
		Path:   "/",
		MaxAge: -1,
	}
	http.SetCookie(w, cookie)
}
1247429
func (self *SimpleCookieMapper) AssociateCookie(w http.ResponseWriter, s Session) {
	cookie := &http.Cookie{
		Name:  self.CookieName(),
		Value: s.SessionId(),
		Path:  "/",
	}
	http.SetCookie(w, cookie)
}
1005456
func (c *Context) Cookie(name string) (string, error) {
	cookie, err := c.Request.Cookie(name)
	if err != nil {
		return "", err
	}
	val, _ := url.QueryUnescape(cookie.Value)
	return val, nil
}