@@ -223,7 +223,7 @@ func (p *OauthProxy) redeemCode(host, code string) (string, string, error) {
223223 return access_token, email, nil
224224}
225225
226−func (p *OauthProxy) ClearCookie(rw http.ResponseWriter, req *http.Request) {
226+func (p *OauthProxy) MakeCookie(req *http.Request, value string, expiration time.Duration) *http.Cookie {
227227 domain := req.Host
228228 if h, _, err := net.SplitHostPort(domain); err == nil {
229229 domain = h
@@ -234,40 +234,28 @@ func (p *OauthProxy) ClearCookie(rw http.ResponseWriter, req *http.Request) {
234234 }
235235 domain = p.CookieDomain
236236 }
237− cookie := &http.Cookie{
237+
238+ if value != "" {
239+ value = signedCookieValue(p.CookieSeed, p.CookieKey, value)
240+ }
241+
242+ return &http.Cookie{
238243 Name: p.CookieKey,
239− Value: "",
244+ Value: value,
240245 Path: "/",
241246 Domain: domain,
242247 HttpOnly: p.CookieHttpOnly,
243248 Secure: p.CookieSecure,
244− Expires: time.Now().Add(time.Duration(1) * time.Hour * -1),
249+ Expires: time.Now().Add(expiration),
245250 }
246− http.SetCookie(rw, cookie)
247251}
248252
249−func (p *OauthProxy) SetCookie(rw http.ResponseWriter, req *http.Request, val string) {
253+func (p *OauthProxy) ClearCookie(rw http.ResponseWriter, req *http.Request) {
254+ http.SetCookie(rw, p.MakeCookie(req, "", time.Duration(1)*time.Hour*-1))
255+}
250256
251− domain := req.Host
252− if h, _, err := net.SplitHostPort(domain); err == nil {
253− domain = h
254− }
255− if p.CookieDomain != "" {
256− if !strings.HasSuffix(domain, p.CookieDomain) {
257− log.Printf("Warning: request host is %q but using configured cookie domain of %q", domain, p.CookieDomain)
258− }
259− domain = p.CookieDomain
260− }
261− cookie := &http.Cookie{
262− Name: p.CookieKey,
263− Value: signedCookieValue(p.CookieSeed, p.CookieKey, val),
264− Path: "/",
265− Domain: domain,
266− HttpOnly: p.CookieHttpOnly,
267− Secure: p.CookieSecure,
268− Expires: time.Now().Add(p.CookieExpire),
269− }
270− http.SetCookie(rw, cookie)
257+func (p *OauthProxy) SetCookie(rw http.ResponseWriter, req *http.Request, val string) {
258+ http.SetCookie(rw, p.MakeCookie(req, val, p.CookieExpire))
271259}
272260
273261func (p *OauthProxy) ProcessCookie(rw http.ResponseWriter, req *http.Request) (email, user, access_token string, ok bool) {