session

package
v1.4.3 Latest Latest
Warning

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

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

This section is empty.

Functions

This section is empty.

Types

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.

Jump to

Keyboard shortcuts

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