skipper: github.com/zalando/skipper/filters/cookie Index | Files

package cookie

import "github.com/zalando/skipper/filters/cookie"

Package cookie implements filters to append to requests or responses.

It implements two filters, one for appending cookies to requests in the "Cookie" header, and one for appending cookies to responses in the "Set-Cookie" header.

Both the request and response cookies expect a name and a value argument.

The response cookie accepts an optional argument to control the max-age property of the cookie, of type number, in seconds.

The response cookie accepts an optional fourth argument, "change-only", to control if the cookie should be set on every response, or only if the request doesn't contain a cookie with the provided name and value. If the fourth argument is "change-only", and a cookie with the same name and value is found in the request, the cookie is not set. This argument can be used to disable sliding TTL of the cookie.

The JS cookie behaves exactly as the response cookie, but it doesn't set the HttpOnly directive, so these cookies will be accessible from JS code running in web browsers.

Examples:

requestCookie("test-session", "abc")

responseCookie("test-session", "abc", 31536000)

responseCookie("test-session", "abc", 31536000, "change-only")

// response cookie without HttpOnly:
jsCookie("test-session-info", "abc-debug", 31536000, "change-only")

Index

Package Files

cookie.go

Constants

const (
    RequestCookieFilterName    = "requestCookie"
    ResponseCookieFilterName   = "responseCookie"
    ResponseJSCookieFilterName = "jsCookie"
    ChangeOnlyArg              = "change-only"
    SetCookieHttpHeader        = "Set-Cookie"
)

func NewJSCookie Uses

func NewJSCookie() filters.Spec

Creates a filter spec for appending cookies to responses without the HttpOnly directive. Name: jsCookie

func NewRequestCookie Uses

func NewRequestCookie() filters.Spec

Creates a filter spec for appending cookies to requests. Name: requestCookie

func NewResponseCookie Uses

func NewResponseCookie() filters.Spec

Creates a filter spec for appending cookies to responses. Name: responseCookie

Package cookie imports 5 packages (graph) and is imported by 3 packages. Updated 2017-05-09. Refresh now. Tools for package owners.