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
6af2778a
authored
2013-05-07 15:36:43 +0800
by
astaxie
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
fix set cookies many times
1 parent
18bf4749
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
14 deletions
context.go
controller.go
context.go
View file @
6af2778
...
...
@@ -66,6 +66,6 @@ func (ctx *Context) SetCookie(name string, value string, age int64) {
}
else
{
utctime
=
time
.
Unix
(
time
.
Now
()
.
Unix
()
+
age
,
0
)
}
cookie
:=
fmt
.
Sprintf
(
"%s=%s;
expires=%s
"
,
name
,
value
,
webTime
(
utctime
))
ctx
.
SetHeader
(
"Set-Cookie"
,
cookie
,
fals
e
)
cookie
:=
fmt
.
Sprintf
(
"%s=%s;
Expires=%s; Path=/
"
,
name
,
value
,
webTime
(
utctime
))
ctx
.
SetHeader
(
"Set-Cookie"
,
cookie
,
tru
e
)
}
...
...
controller.go
View file @
6af2778
...
...
@@ -27,6 +27,7 @@ type Controller struct {
TplNames
string
Layout
string
TplExt
string
CruSession
session
.
SessionStore
}
type
ControllerInterface
interface
{
...
...
@@ -58,6 +59,9 @@ func (c *Controller) Prepare() {
}
func
(
c
*
Controller
)
Finish
()
{
if
c
.
CruSession
!=
nil
{
c
.
CruSession
.
SessionRelease
()
}
}
func
(
c
*
Controller
)
Get
()
{
...
...
@@ -259,25 +263,30 @@ func (c *Controller) SaveToFile(fromfile, tofile string) error {
return
nil
}
func
(
c
*
Controller
)
StartSession
()
(
sess
session
.
SessionStore
)
{
sess
=
GlobalSessions
.
SessionStart
(
c
.
Ctx
.
ResponseWriter
,
c
.
Ctx
.
Request
)
return
func
(
c
*
Controller
)
StartSession
()
session
.
SessionStore
{
if
c
.
CruSession
==
nil
{
c
.
CruSession
=
GlobalSessions
.
SessionStart
(
c
.
Ctx
.
ResponseWriter
,
c
.
Ctx
.
Request
)
}
return
c
.
CruSession
}
func
(
c
*
Controller
)
SetSession
(
name
string
,
value
interface
{})
{
ss
:=
c
.
StartSession
()
defer
ss
.
SessionRelease
()
ss
.
Set
(
name
,
value
)
if
c
.
CruSession
==
nil
{
c
.
StartSession
()
}
c
.
CruSession
.
Set
(
name
,
value
)
}
func
(
c
*
Controller
)
GetSession
(
name
string
)
interface
{}
{
ss
:=
c
.
StartSession
()
defer
ss
.
SessionRelease
()
return
ss
.
Get
(
name
)
if
c
.
CruSession
==
nil
{
c
.
StartSession
()
}
return
c
.
CruSession
.
Get
(
name
)
}
func
(
c
*
Controller
)
DelSession
(
name
string
)
{
ss
:=
c
.
StartSession
()
defer
ss
.
SessionRelease
()
ss
.
Delete
(
name
)
if
c
.
CruSession
==
nil
{
c
.
StartSession
()
}
c
.
CruSession
.
Delete
(
name
)
}
...
...
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