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
db06e954
authored
2015-05-28 12:04:19 +0800
by
astaxie
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
fix the session memcache bug
1 parent
3abd0179
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
7 deletions
session/memcache/sess_memcache.go
session/session.go
session/memcache/sess_memcache.go
View file @
db06e95
...
...
@@ -129,8 +129,9 @@ func (rp *MemProvider) SessionRead(sid string) (session.SessionStore, error) {
}
}
item
,
err
:=
client
.
Get
(
sid
)
if
err
!=
nil
{
return
nil
,
err
if
err
!=
nil
&&
err
==
memcache
.
ErrCacheMiss
{
rs
:=
&
MemcacheSessionStore
{
sid
:
sid
,
values
:
make
(
map
[
interface
{}]
interface
{}),
maxlifetime
:
rp
.
maxlifetime
}
return
rs
,
nil
}
var
kv
map
[
interface
{}]
interface
{}
if
len
(
item
.
Value
)
==
0
{
...
...
@@ -141,7 +142,6 @@ func (rp *MemProvider) SessionRead(sid string) (session.SessionStore, error) {
return
nil
,
err
}
}
rs
:=
&
MemcacheSessionStore
{
sid
:
sid
,
values
:
kv
,
maxlifetime
:
rp
.
maxlifetime
}
return
rs
,
nil
}
...
...
session/session.go
View file @
db06e95
...
...
@@ -143,12 +143,14 @@ func (manager *Manager) SessionStart(w http.ResponseWriter, r *http.Request) (se
return
nil
,
errs
}
session
,
err
=
manager
.
provider
.
SessionRead
(
sid
)
cookie
=
&
http
.
Cookie
{
Name
:
manager
.
config
.
CookieName
,
cookie
=
&
http
.
Cookie
{
Name
:
manager
.
config
.
CookieName
,
Value
:
url
.
QueryEscape
(
sid
),
Path
:
"/"
,
HttpOnly
:
true
,
Secure
:
manager
.
isSecure
(
r
),
Domain
:
manager
.
config
.
Domain
}
Domain
:
manager
.
config
.
Domain
,
}
if
manager
.
config
.
CookieLifeTime
>
0
{
cookie
.
MaxAge
=
manager
.
config
.
CookieLifeTime
cookie
.
Expires
=
time
.
Now
()
.
Add
(
time
.
Duration
(
manager
.
config
.
CookieLifeTime
)
*
time
.
Second
)
...
...
@@ -170,12 +172,14 @@ func (manager *Manager) SessionStart(w http.ResponseWriter, r *http.Request) (se
return
nil
,
err
}
session
,
err
=
manager
.
provider
.
SessionRead
(
sid
)
cookie
=
&
http
.
Cookie
{
Name
:
manager
.
config
.
CookieName
,
cookie
=
&
http
.
Cookie
{
Name
:
manager
.
config
.
CookieName
,
Value
:
url
.
QueryEscape
(
sid
),
Path
:
"/"
,
HttpOnly
:
true
,
Secure
:
manager
.
isSecure
(
r
),
Domain
:
manager
.
config
.
Domain
}
Domain
:
manager
.
config
.
Domain
,
}
if
manager
.
config
.
CookieLifeTime
>
0
{
cookie
.
MaxAge
=
manager
.
config
.
CookieLifeTime
cookie
.
Expires
=
time
.
Now
()
.
Add
(
time
.
Duration
(
manager
.
config
.
CookieLifeTime
)
*
time
.
Second
)
...
...
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