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/ECacheFS/beego/session/mysql" "github.com/ECacheFS/beego/session"
)
func init() { globalSessions, _ = session.NewManager("mysql", ``{"cookieName":"gosessionid","gclifetime":3600,"ProviderConfig":"[username[:password]@][protocol[(address)]]/dbname[?param1=value1&...¶mN=valueN]"}``) go globalSessions.GC() }
more docs: http://beego.me/docs/module/session.md
Index ¶
- Variables
- type Provider
- func (mp *Provider) SessionAll() int
- func (mp *Provider) SessionDestroy(sid string) error
- func (mp *Provider) SessionExist(sid string) bool
- func (mp *Provider) SessionGC()
- func (mp *Provider) SessionInit(maxlifetime int64, savePath string) error
- func (mp *Provider) SessionRead(sid string) (session.Store, error)
- func (mp *Provider) SessionRegenerate(oldsid, sid string) (session.Store, error)
- type SessionStore
- func (st *SessionStore) Delete(key interface{}) error
- func (st *SessionStore) Flush() error
- func (st *SessionStore) Get(key interface{}) interface{}
- func (st *SessionStore) SessionID() string
- func (st *SessionStore) SessionRelease(w http.ResponseWriter)
- func (st *SessionStore) Set(key, value interface{}) error
Constants ¶
This section is empty.
Variables ¶
var (
// TableName store the session in MySQL
TableName = "session"
)
Functions ¶
This section is empty.
Types ¶
type Provider ¶ added in v1.6.0
type Provider struct {
// contains filtered or unexported fields
}
Provider mysql session provider
func (*Provider) SessionAll ¶ added in v1.6.0
SessionAll count values in mysql session
func (*Provider) SessionDestroy ¶ added in v1.6.0
SessionDestroy delete mysql session by sid
func (*Provider) SessionExist ¶ added in v1.6.0
SessionExist check mysql session exist
func (*Provider) SessionGC ¶ added in v1.6.0
func (mp *Provider) SessionGC()
SessionGC delete expired values in mysql session
func (*Provider) SessionInit ¶ added in v1.6.0
SessionInit init mysql session. savepath is the connection string of mysql.
func (*Provider) SessionRead ¶ added in v1.6.0
SessionRead get mysql session by sid
type SessionStore ¶ added in v1.6.0
type SessionStore struct {
// contains filtered or unexported fields
}
SessionStore mysql session store
func (*SessionStore) Delete ¶ added in v1.6.0
func (st *SessionStore) Delete(key interface{}) error
Delete value in mysql session
func (*SessionStore) Flush ¶ added in v1.6.0
func (st *SessionStore) Flush() error
Flush clear all values in mysql session
func (*SessionStore) Get ¶ added in v1.6.0
func (st *SessionStore) Get(key interface{}) interface{}
Get value from mysql session
func (*SessionStore) SessionID ¶ added in v1.6.0
func (st *SessionStore) SessionID() string
SessionID get session id of this mysql session store
func (*SessionStore) SessionRelease ¶ added in v1.6.0
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 ¶ added in v1.6.0
func (st *SessionStore) Set(key, value interface{}) error
Set value in mysql session. it is temp value in map.