Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
B
beego
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
go
beego
Commits
d7a5281b
Commit
d7a5281b
authored
Aug 04, 2014
by
astaxie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
session: support cookie domain
parent
474a16a7
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
8 additions
and
2 deletions
+8
-2
beego.go
beego.go
+1
-0
config.go
config.go
+1
-0
session.go
session/session.go
+6
-2
No files found.
beego.go
View file @
d7a5281b
...
...
@@ -362,6 +362,7 @@ func initBeforeHttpRun() {
`"sessionIDHashFunc":"`
+
SessionHashFunc
+
`",`
+
`"sessionIDHashKey":"`
+
SessionHashKey
+
`",`
+
`"enableSetCookie":`
+
strconv
.
FormatBool
(
SessionAutoSetCookie
)
+
`,`
+
`"domain":`
+
SessionDomain
+
`,`
+
`"cookieLifeTime":`
+
strconv
.
Itoa
(
SessionCookieLifeTime
)
+
`}`
}
GlobalSessions
,
err
=
session
.
NewManager
(
SessionProvider
,
...
...
config.go
View file @
d7a5281b
...
...
@@ -55,6 +55,7 @@ var (
SessionHashKey
string
// session hash salt string.
SessionCookieLifeTime
int
// the life time of session id in cookie.
SessionAutoSetCookie
bool
// auto setcookie
SessionDomain
string
// the cookie domain default is empty
UseFcgi
bool
MaxMemory
int64
EnableGzip
bool
// flag of enable gzip
...
...
session/session.go
View file @
d7a5281b
...
...
@@ -72,6 +72,7 @@ type managerConfig struct {
SessionIDHashKey
string
`json:"sessionIDHashKey"`
CookieLifeTime
int
`json:"cookieLifeTime"`
ProviderConfig
string
`json:"providerConfig"`
Domain
string
`json:"domain"`
}
// Manager contains Provider and its configuration.
...
...
@@ -134,7 +135,8 @@ func (manager *Manager) SessionStart(w http.ResponseWriter, r *http.Request) (se
Value
:
url
.
QueryEscape
(
sid
),
Path
:
"/"
,
HttpOnly
:
true
,
Secure
:
manager
.
config
.
Secure
}
Secure
:
manager
.
config
.
Secure
,
Domain
:
manager
.
config
.
Domain
}
if
manager
.
config
.
CookieLifeTime
>=
0
{
cookie
.
MaxAge
=
manager
.
config
.
CookieLifeTime
}
...
...
@@ -153,7 +155,8 @@ func (manager *Manager) SessionStart(w http.ResponseWriter, r *http.Request) (se
Value
:
url
.
QueryEscape
(
sid
),
Path
:
"/"
,
HttpOnly
:
true
,
Secure
:
manager
.
config
.
Secure
}
Secure
:
manager
.
config
.
Secure
,
Domain
:
manager
.
config
.
Domain
}
if
manager
.
config
.
CookieLifeTime
>=
0
{
cookie
.
MaxAge
=
manager
.
config
.
CookieLifeTime
}
...
...
@@ -208,6 +211,7 @@ func (manager *Manager) SessionRegenerateId(w http.ResponseWriter, r *http.Reque
Path
:
"/"
,
HttpOnly
:
true
,
Secure
:
manager
.
config
.
Secure
,
Domain
:
manager
.
config
.
Domain
,
}
}
else
{
oldsid
,
_
:=
url
.
QueryUnescape
(
cookie
.
Value
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment