sessionredis

package module
v0.0.0-...-7921e7a Latest Latest
Warning

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

Go to latest
Published: Feb 23, 2017 License: MIT Imports: 7 Imported by: 0

README

session-redis

Build Status Coverage Status License GoDoc

A session store backend for cookie-session

Installation

go get github.com/mushroomsir/session-redis

##Examples

go run example/main.go

##Usage

    SessionName := "Sess"
	SessionKeys := []string{"keyxxx"}

    store := sessionredis.New()
	handler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
	    session := &Session{Meta: &sessions.Meta{}}
		store.Load(SessionName, session, cookie.New(w, r, SessionKeys...))
		if session.UserID == "" {
			session.UserID = "x"
			session.Name = "y"
			session.Authed = 1
		}
		session.Save()
	})

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewUUID

func NewUUID() (string, error)

NewUUID generates a random UUID according to RFC 4122

Types

type Options

type Options struct {
	Addr       string
	Expiration time.Duration
	DB         int
	Password   string
	// contains filtered or unexported fields
}

Options ...

type RedisStore

type RedisStore struct {
	// contains filtered or unexported fields
}

RedisStore backend for cookie-session

func New

func New(options ...*Options) (store *RedisStore)

New an CookieStore instance

func (*RedisStore) Load

func (c *RedisStore) Load(name string, session sessions.Sessions, cookie *cookie.Cookies) (err error)

Load existed session from Request's cookies

func (*RedisStore) Save

func (c *RedisStore) Save(session sessions.Sessions) (err error)

Save session to Response's cookie

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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