1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
package community
import (
"net/http"
"net/http/cookiejar"
"net/url"
)
const cookiePath = "https://steamcommunity.com/"
func SetCookies(client *http.Client, sessionId, steamLogin, steamLoginSecure string) {
if client.Jar == nil {
client.Jar, _ = cookiejar.New(new(cookiejar.Options))
}
base, err := url.Parse(cookiePath)
if err != nil {
panic(err)
}
client.Jar.SetCookies(base, []*http.Cookie{
// It seems that, for some reason, Steam tries to URL-decode the cookie.
&http.Cookie{
Name: "sessionid",
Value: url.QueryEscape(sessionId),
},
// steamLogin is already URL-encoded.
&http.Cookie{
Name: "steamLogin",
Value: steamLogin,
},
&http.Cookie{
Name: "steamLoginSecure",
Value: steamLoginSecure,
},
})
}
|