Skip to content

Commit 0d091bf

Browse files
committed
Adds cookie domain support
1 parent a5b8524 commit 0d091bf

File tree

4 files changed

+8
-1
lines changed

4 files changed

+8
-1
lines changed

revel.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,8 @@ var (
6666

6767
// All cookies dropped by the framework begin with this prefix.
6868
CookiePrefix string
69-
69+
// Cookie domain
70+
CookieDomain string
7071
// Cookie flags
7172
CookieHttpOnly bool
7273
CookieSecure bool
@@ -181,6 +182,7 @@ func Init(mode, importPath, srcPath string) {
181182
AppName = Config.StringDefault("app.name", "(not set)")
182183
AppRoot = Config.StringDefault("app.root", "")
183184
CookiePrefix = Config.StringDefault("cookie.prefix", "REVEL")
185+
CookieDomain = Config.StringDefault("cookie.domain", "")
184186
CookieHttpOnly = Config.BoolDefault("cookie.httponly", false)
185187
CookieSecure = Config.BoolDefault("cookie.secure", false)
186188
TemplateDelims = Config.StringDefault("template.delimiters", "")

session.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ func (s Session) Cookie() *http.Cookie {
8585
return &http.Cookie{
8686
Name: CookiePrefix + "_SESSION",
8787
Value: Sign(sessionData) + "-" + sessionData,
88+
Domain: CookieDomain,
8889
Path: "/",
8990
HttpOnly: CookieHttpOnly,
9091
Secure: CookieSecure,

skeleton/conf/app.conf.template

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ cookie.prefix = REVEL
5353
# eavesdropping.
5454
cookie.secure = false
5555

56+
# Limit cookie access to a given domain
57+
#cookie.domain =
5658

5759
# Define when your session cookie expires. Possible values:
5860
# "720h"

validation.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,7 @@ func ValidationFilter(c *Controller, fc []Filter) {
210210
c.SetCookie(&http.Cookie{
211211
Name: CookiePrefix + "_ERRORS",
212212
Value: url.QueryEscape(errorsValue),
213+
Domain: CookieDomain,
213214
Path: "/",
214215
HttpOnly: CookieHttpOnly,
215216
Secure: CookieSecure,
@@ -218,6 +219,7 @@ func ValidationFilter(c *Controller, fc []Filter) {
218219
c.SetCookie(&http.Cookie{
219220
Name: CookiePrefix + "_ERRORS",
220221
MaxAge: -1,
222+
Domain: CookieDomain,
221223
Path: "/",
222224
HttpOnly: CookieHttpOnly,
223225
Secure: CookieSecure,

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy