sessions

package module
v0.0.0-...-c09dbb4 Latest Latest
Warning

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

Go to latest
Published: Dec 31, 2014 License: MIT Imports: 11 Imported by: 1

README

#sessions GoDoc GoCover

Neko middleware/handler that provides a Session service.

Usage

package main
import (
  "github.com/rocwong/neko"
  "github.com/neko-contrib/sessions"
)

func main() {
  m := neko.New()

  m.Use(sessions.Sessions("sess_neko", sessions.NewCookieStore([]byte("secret123"))))

  m.GET("/", func (ctx *neko.Context) {
    ctx.Session.Set("myvalue", "Session Save")
    ctx.Text("Session Save")
  })
  m.GET("/get", func (ctx *neko.Context) {
    ctx.Text(ctx.Session.Get("myvalue"))
  })

  m.GET("/flash", func (ctx *neko.Context) {
    ctx.Session.AddFlash("Flash Session")
    ctx.Text("Flash Save")
  })
  m.GET("/getflash", func (ctx *neko.Context) {
    ctx.Text(ctx.Session.Flashes())
  })

  m.Run(":3000")
}

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidId       = errors.New("session: invalid session id")
	ErrInvalidModified = errors.New("mongostore: invalid modified value")
)

Functions

func NewCookieStore

func NewCookieStore(keyPairs ...[]byte) neko.SessionStore

NewCookieStore returns a new CookieStore.

func NewMongoStore

func NewMongoStore(session mgo.Session, database string, collection string, maxAge int, ensureTTL bool, keyPairs ...[]byte) neko.SessionStore

func NewRediStore

func NewRediStore(size int, network, address, password string, keyPairs ...[]byte) (neko.SessionStore, error)

func Sessions

func Sessions(name string, store neko.SessionStore) neko.HandlerFunc

Types

This section is empty.

Jump to

Keyboard shortcuts

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