cookie

package module
v0.0.0-...-8ba63e6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 30, 2015 License: MIT Imports: 4 Imported by: 1

README

GoDoc

This Library implements convenience functions for manipulating cookies in a Gopherjs application.

Installation

Install with go get:

go get github.com/fabioberger/cookie

Then include the package in your imports:

import "github.com/fabioberger/cookie"

Example Usage

Set Cookie:

expires := time.Now().Add(time.Hour) // Set expiry time to in one hour
cookie.Set("username", "John Doe", &expires, "/")

// Or

// set cookie with correctly formatted string
cookie.SetString("username=John Doe; expires=Thu, 18 Dec 2013 12:00:00 UTC; path=/")

Get Cookie:

username, ok := cookie.Get("username")
if !ok {
	// Cookie was not found
}

Delete Cookie:

cookie.Delete("username")

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Delete

func Delete(name string)

Delete removes a cookie specified by name

func Get

func Get(name string) (value string, ok bool)

Get returns a given cookie by name. If the cookie is not set, ok will be set to false

func Set

func Set(name string, value string, expires *time.Time, path string)

Set adds a cookie to a user's browser with a name, value, expiry and path value, path and expires can be omitted

func SetString

func SetString(cookie string)

SetString sets a cookie given a correctly formatted cookie string i.e "username=John Smith; expires=Thu, 18 Dec 2013 12:00:00 UTC; path=/"

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL