Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
张磊
/
FileStorageBeego
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
23d79b8b
authored
2013-11-03 21:41:07 +0800
by
astaxie
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
#254 add SessionHashFunc SessionHashKey SessionCookieLifeTime
1 parent
9ccdb310
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
32 additions
and
1 deletions
beego.go
config.go
beego.go
View file @
23d79b8
...
...
@@ -71,7 +71,14 @@ func Run() {
}
if
SessionOn
{
GlobalSessions
,
_
=
session
.
NewManager
(
SessionProvider
,
SessionName
,
SessionGCMaxLifetime
,
SessionSavePath
,
HttpTLS
)
GlobalSessions
,
_
=
session
.
NewManager
(
SessionProvider
,
SessionName
,
SessionGCMaxLifetime
,
SessionSavePath
,
HttpTLS
,
SessionHashFunc
,
SessionHashKey
,
SessionCookieLifeTime
)
go
GlobalSessions
.
GC
()
}
...
...
config.go
View file @
23d79b8
...
...
@@ -36,6 +36,9 @@ var (
SessionName
string
// sessionName cookie's name
SessionGCMaxLifetime
int64
// session's gc maxlifetime
SessionSavePath
string
// session savepath if use mysql/redis/file this set to the connectinfo
SessionHashFunc
string
SessionHashKey
string
SessionCookieLifeTime
int
UseFcgi
bool
MaxMemory
int64
EnableGzip
bool
// enable gzip
...
...
@@ -71,6 +74,9 @@ func init() {
SessionName
=
"beegosessionID"
SessionGCMaxLifetime
=
3600
SessionSavePath
=
""
SessionHashFunc
=
"sha1"
SessionHashKey
=
"beegoserversessionkey"
SessionCookieLifeTime
=
3600
UseFcgi
=
false
MaxMemory
=
1
<<
26
//64MB
EnableGzip
=
false
...
...
@@ -157,6 +163,18 @@ func ParseConfig() (err error) {
if
sesssavepath
:=
AppConfig
.
String
(
"SessionSavePath"
);
sesssavepath
!=
""
{
SessionSavePath
=
sesssavepath
}
if
sesshashfunc
:=
AppConfig
.
String
(
"sessionhashfunc"
);
sesshashfunc
!=
""
{
SessionHashFunc
=
sesshashfunc
}
if
sesshashfunc
:=
AppConfig
.
String
(
"SessionHashFunc"
);
sesshashfunc
!=
""
{
SessionHashFunc
=
sesshashfunc
}
if
sesshashkey
:=
AppConfig
.
String
(
"sessionhashkey"
);
sesshashkey
!=
""
{
SessionHashKey
=
sesshashkey
}
if
sesshashkey
:=
AppConfig
.
String
(
"SessionHashKey"
);
sesshashkey
!=
""
{
SessionHashKey
=
sesshashkey
}
if
sessMaxLifeTime
,
err
:=
AppConfig
.
Int
(
"sessiongcmaxlifetime"
);
err
==
nil
&&
sessMaxLifeTime
!=
0
{
int64val
,
_
:=
strconv
.
ParseInt
(
strconv
.
Itoa
(
sessMaxLifeTime
),
10
,
64
)
SessionGCMaxLifetime
=
int64val
...
...
@@ -165,6 +183,12 @@ func ParseConfig() (err error) {
int64val
,
_
:=
strconv
.
ParseInt
(
strconv
.
Itoa
(
sessMaxLifeTime
),
10
,
64
)
SessionGCMaxLifetime
=
int64val
}
if
sesscookielifetime
,
err
:=
AppConfig
.
Int
(
"sessioncookielifelime"
);
err
==
nil
&&
sesscookielifetime
!=
0
{
SessionCookieLifeTime
=
sesscookielifetime
}
if
sesscookielifetime
,
err
:=
AppConfig
.
Int
(
"SessionCookieLifeTime"
);
err
==
nil
&&
sesscookielifetime
!=
0
{
SessionCookieLifeTime
=
sesscookielifetime
}
if
usefcgi
,
err
:=
AppConfig
.
Bool
(
"usefcgi"
);
err
==
nil
{
UseFcgi
=
usefcgi
}
...
...
Write
Preview
Styling with
Markdown
is supported
Attach a file
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 post a comment