// Set cookie with https.
13621
func (manager *Manager) isSecure(req *http.Request) bool {
	if !manager.config.Secure {
		return false
	}
	if req.URL.Scheme != "" {
		return req.URL.Scheme == "https"
	}
	if req.TLS == nil {
		return false
	}
	return true
}
489680
func (s *EnvironmentVariable) SetSecure(v bool) *EnvironmentVariable {
	s.Secure = &v
	return s
}
353606
func SetSecureCookiePathWithFlags(w http.ResponseWriter, name, val string, age int64, path string, cookieSecret string, secure, httponly bool) {
	// base64 encode the value
	if len(cookieSecret) == 0 {
		log.Fatalln("Secret Key for secure cookies has not been set. Please use a non-empty secret.")
	}
	var buf bytes.Buffer
	encoder := base64.NewEncoder(base64.StdEncoding, &buf)
	encoder.Write([]byte(val))
	encoder.Close()
	vs := buf.String()
	vb := buf.Bytes()
	timestamp := strconv.FormatInt(time.Now().Unix(), 10)
	sig := Signature(cookieSecret, vb, timestamp)
	cookie := strings.Join([]string{vs, timestamp, sig}, "|")
	SetCookiePathWithFlags(w, name, cookie, age, path, secure, httponly)
}
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
}
844725
func (self *HttpClient) SetCookieJar(jar http.CookieJar) {
	self.client.Jar = jar
}
255944
func (c *cookie) Expire(w http.ResponseWriter) {
	// to expire cookie set the time in the past
	cookie := http.Cookie{
		Name:     DefaultCookieName,
		Value:    "none",
		HttpOnly: true,
		Path:     "/",
		Expires:  c.Now().Add(-1 * time.Hour),
	}

	http.SetCookie(w, &cookie)
}
308609
func (self *Commands) Set(cookie *Cookie) error {
	if response, err := self.browser.Tab().RPC(`Network`, `setCookie`, cookie.native()); err == nil {
		if response.R().Bool(`success`) {
			return nil
		} else {
			return fmt.Errorf("Failed to set cookie")
		}
	} else {
		return err
	}
}
257242
func (ctx *context) SetCookie(cookie *http.Cookie, options ...CookieOption) {
	for _, opt := range options {
		opt(cookie)
	}

	http.SetCookie(ctx.writer, cookie)
}
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)
}
641144
func (ctx *Context) SetCookie(cookie *http.Cookie) {
	ctx.SetHeader("Set-Cookie", cookie.String(), false)
}
803184
func (c Context) Cookie(name string) string {
	cookies := c.Req.Cookies()
	for _, cookie := range cookies {
		if cookie.Name == name {
			return cookie.Value
		}
	}
	return ""
}
551590
func (s *AuthenticationService) SetCookieAuth(name, value string) {
	s.name = name
	s.secret = value
	s.authType = authTypeCookie
}
86805
func (c *Context) Cookies() []*http.Cookie {
	return c.Client.Jar.Cookies(c.Request().URL)
}
1354656
func Set(key, value string) p.Plugin {
	return p.NewRequestPlugin(func(ctx *c.Context, h c.Handler) {
		cookie := &http.Cookie{Name: key, Value: value}
		ctx.Request.AddCookie(cookie)
		h.Next(ctx)
	})
}
970523
func (r *Request) SetCookie(cookie *http.Cookie) *Request {
	r.req.Header.Add("Cookie", cookie.String())
	return r
}
1025704
func SetUserCookie(w http.ResponseWriter, r *http.Request, user User) {

	cookie := &http.Cookie{
		Name:     Config.CookieName,
		Path:     "/",
		Domain:   r.URL.Host,
		HttpOnly: Config.CookieHttpOnly,
		Secure:   Config.CookieSecure,
	}

	// if not a session cookie set the MaxAge
	if Config.CookieMaxAge > 0 {
		cookie.MaxAge = Config.CookieMaxAge
	}

	SetUserCookieOpts(w, cookie, user)
}
231867
func SetCookiePathWithFlags(w http.ResponseWriter, name, value string, age int64, path string, secure, httponly bool) {
	var utctime time.Time
	if age == 0 {
		// 2^31 - 1 seconds (roughly 2038)
		utctime = time.Unix(2147483647, 0)
	} else {
		utctime = time.Unix(time.Now().Unix()+age, 0)
	}
	cookie := http.Cookie{Name: name, Value: value, Expires: utctime, Path: path, Secure: secure, HttpOnly: httponly}
	SetHeader(w, "Set-Cookie", cookie.String(), false)
}