Version: v1.4.3 Latest Latest

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

Go to latest
Published: Feb 27, 2015 License: Apache-2.0 Imports: 6 Imported by: 0



package mysql for session provider

depends on

go install

mysql session support need create table as sql:

CREATE TABLE `session` (
`session_key` char(64) NOT NULL,
session_data` blob,
`session_expiry` int(11) unsigned NOT NULL,
PRIMARY KEY (`session_key`)

Usage: import(

_ ""


func init() {
	globalSessions, _ = session.NewManager("mysql", “{"cookieName":"gosessionid","gclifetime":3600,"ProviderConfig":"[username[:password]@][protocol[(address)]]/dbname[?param1=value1&...&paramN=valueN]"}“)
	go globalSessions.GC()

more docs:



This section is empty.


This section is empty.


This section is empty.


type MysqlProvider

type MysqlProvider struct {
	// contains filtered or unexported fields

mysql session provider

func (*MysqlProvider) SessionAll

func (mp *MysqlProvider) SessionAll() int

count values in mysql session

func (*MysqlProvider) SessionDestroy

func (mp *MysqlProvider) SessionDestroy(sid string) error

delete mysql session by sid

func (*MysqlProvider) SessionExist

func (mp *MysqlProvider) SessionExist(sid string) bool

check mysql session exist

func (*MysqlProvider) SessionGC

func (mp *MysqlProvider) SessionGC()

delete expired values in mysql session

func (*MysqlProvider) SessionInit

func (mp *MysqlProvider) SessionInit(maxlifetime int64, savePath string) error

init mysql session. savepath is the connection string of mysql.

func (*MysqlProvider) SessionRead

func (mp *MysqlProvider) SessionRead(sid string) (session.SessionStore, error)

get mysql session by sid

func (*MysqlProvider) SessionRegenerate

func (mp *MysqlProvider) SessionRegenerate(oldsid, sid string) (session.SessionStore, error)

generate new sid for mysql session

type MysqlSessionStore

type MysqlSessionStore struct {
	// contains filtered or unexported fields

mysql session store

func (*MysqlSessionStore) Delete

func (st *MysqlSessionStore) Delete(key interface{}) error

delete value in mysql session

func (*MysqlSessionStore) Flush

func (st *MysqlSessionStore) Flush() error

clear all values in mysql session

func (*MysqlSessionStore) Get

func (st *MysqlSessionStore) Get(key interface{}) interface{}

get value from mysql session

func (*MysqlSessionStore) SessionID

func (st *MysqlSessionStore) SessionID() string

get session id of this mysql session store

func (*MysqlSessionStore) SessionRelease

func (st *MysqlSessionStore) SessionRelease(w http.ResponseWriter)

save mysql session values to database. must call this method to save values to database.

func (*MysqlSessionStore) Set

func (st *MysqlSessionStore) Set(key, value interface{}) error

set value in mysql session. it is temp value in map.

Source Files

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL