mysql

package
v1.8.0 Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2017 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package mysql for session provider

depends on github.com/go-sql-driver/mysql:

go install github.com/go-sql-driver/mysql

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`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

Usage: import(

_ "github.com/astaxie/beego/session/mysql"
"github.com/astaxie/beego/session"

)

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: http://beego.me/docs/module/session.md

Index

Constants

This section is empty.

Variables

View Source
var (
	// TableName store the session in MySQL
	TableName = "session"
)

Functions

This section is empty.

Types

type Provider

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

Provider mysql session provider

func (*Provider) SessionAll

func (mp *Provider) SessionAll() int

SessionAll count values in mysql session

func (*Provider) SessionDestroy

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

SessionDestroy delete mysql session by sid

func (*Provider) SessionExist

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

SessionExist check mysql session exist

func (*Provider) SessionGC

func (mp *Provider) SessionGC()

SessionGC delete expired values in mysql session

func (*Provider) SessionInit

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

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

func (*Provider) SessionRead

func (mp *Provider) SessionRead(sid string) (session.Store, error)

SessionRead get mysql session by sid

func (*Provider) SessionRegenerate

func (mp *Provider) SessionRegenerate(oldsid, sid string) (session.Store, error)

SessionRegenerate generate new sid for mysql session

type SessionStore

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

SessionStore mysql session store

func (*SessionStore) Delete

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

Delete value in mysql session

func (*SessionStore) Flush

func (st *SessionStore) Flush() error

Flush clear all values in mysql session

func (*SessionStore) Get

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

Get value from mysql session

func (*SessionStore) SessionID

func (st *SessionStore) SessionID() string

SessionID get session id of this mysql session store

func (*SessionStore) SessionRelease

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

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

func (*SessionStore) Set

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

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

Jump to

Keyboard shortcuts

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