mirror of
https://github.com/jeessy2/ddns-go.git
synced 2025-10-20 23:43:45 +08:00
24 lines
493 B
Go
Executable File
24 lines
493 B
Go
Executable File
package web
|
|
|
|
import (
|
|
"net/http"
|
|
"time"
|
|
)
|
|
|
|
func Logout(w http.ResponseWriter, r *http.Request) {
|
|
// 覆盖cookieInSystem
|
|
cookieInSystem = &http.Cookie{
|
|
Name: cookieName,
|
|
Value: "",
|
|
Path: "/",
|
|
Expires: time.Unix(0, 0), // 设置为过期时间
|
|
MaxAge: -1, // 立即删除该 Cookie
|
|
HttpOnly: true,
|
|
}
|
|
// 设置过期的 Cookie
|
|
http.SetCookie(w, cookieInSystem)
|
|
|
|
// 重定向用户到登录页面
|
|
http.Redirect(w, r, "./login", http.StatusFound)
|
|
}
|