调整cookie写入方法
This commit is contained in:
@@ -14,7 +14,12 @@ func ClearToken(c *gin.Context) {
|
||||
if err != nil {
|
||||
host = c.Request.Host
|
||||
}
|
||||
c.SetCookie("x-token", "", -1, "/", host, true, false)
|
||||
|
||||
if net.ParseIP(host) != nil {
|
||||
c.SetCookie("x-token", "", -1, "/", "", false, false)
|
||||
} else {
|
||||
c.SetCookie("x-token", "", -1, "/", host, false, false)
|
||||
}
|
||||
}
|
||||
|
||||
func SetToken(c *gin.Context, token string, maxAge int) {
|
||||
@@ -23,7 +28,12 @@ func SetToken(c *gin.Context, token string, maxAge int) {
|
||||
if err != nil {
|
||||
host = c.Request.Host
|
||||
}
|
||||
c.SetCookie("x-token", token, maxAge, "/", host, true, false)
|
||||
|
||||
if net.ParseIP(host) != nil {
|
||||
c.SetCookie("x-token", token, maxAge, "/", "", false, false)
|
||||
} else {
|
||||
c.SetCookie("x-token", token, maxAge, "/", host, false, false)
|
||||
}
|
||||
}
|
||||
|
||||
func GetToken(c *gin.Context) string {
|
||||
|
Reference in New Issue
Block a user