Skip to content

Commit 8154739

Browse files
authored
Adds support for SameSite cookie attribute (#165)
1 parent a12d857 commit 8154739

File tree

3 files changed

+40
-17
lines changed

3 files changed

+40
-17
lines changed

options.go

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// +build !go1.11
2+
3+
package sessions
4+
5+
// Options stores configuration for a session or session store.
6+
//
7+
// Fields are a subset of http.Cookie fields.
8+
type Options struct {
9+
Path string
10+
Domain string
11+
// MaxAge=0 means no Max-Age attribute specified and the cookie will be
12+
// deleted after the browser session ends.
13+
// MaxAge<0 means delete cookie immediately.
14+
// MaxAge>0 means Max-Age attribute present and given in seconds.
15+
MaxAge int
16+
Secure bool
17+
HttpOnly bool
18+
}

options_go111.go

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// +build go1.11
2+
3+
package sessions
4+
5+
import "net/http"
6+
7+
// Options stores configuration for a session or session store.
8+
//
9+
// Fields are a subset of http.Cookie fields.
10+
type Options struct {
11+
Path string
12+
Domain string
13+
// MaxAge=0 means no Max-Age attribute specified and the cookie will be
14+
// deleted after the browser session ends.
15+
// MaxAge<0 means delete cookie immediately.
16+
// MaxAge>0 means Max-Age attribute present and given in seconds.
17+
MaxAge int
18+
Secure bool
19+
HttpOnly bool
20+
// Defaults to http.SameSiteDefaultMode
21+
SameSite http.SameSite
22+
}

sessions.go

-17
Original file line numberDiff line numberDiff line change
@@ -16,23 +16,6 @@ import (
1616
// Default flashes key.
1717
const flashesKey = "_flash"
1818

19-
// Options --------------------------------------------------------------------
20-
21-
// Options stores configuration for a session or session store.
22-
//
23-
// Fields are a subset of http.Cookie fields.
24-
type Options struct {
25-
Path string
26-
Domain string
27-
// MaxAge=0 means no Max-Age attribute specified and the cookie will be
28-
// deleted after the browser session ends.
29-
// MaxAge<0 means delete cookie immediately.
30-
// MaxAge>0 means Max-Age attribute present and given in seconds.
31-
MaxAge int
32-
Secure bool
33-
HttpOnly bool
34-
}
35-
3619
// Session --------------------------------------------------------------------
3720

3821
// NewSession is called by session stores to create a new session instance.

0 commit comments

Comments
 (0)