You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
go-fly/tools/cookie.go

31 lines
541 B

package tools
import (
"net/http"
"strings"
)
func GetCookie(r *http.Request, name string) string {
cookies := r.Cookies()
for _, cookie := range cookies {
if cookie.Name == name {
return cookie.Value
}
}
return ""
}
func GetMailServerFromCookie(r *http.Request)*MailServer{
auth := GetCookie(r, "auth")
if !strings.Contains(auth, "|") {
return nil
}
authStrings := strings.Split(auth, "|")
mailServer:=&MailServer{
Server:authStrings[0],
Email: authStrings[1],
Password: authStrings[2],
}
return mailServer
}