beego: Index | Files

package postgres

import ""

Package postgres for session provider

depends on

go install

needs this table in your database:

CREATE TABLE session ( session_key char(64) NOT NULL, session_data bytea, session_expiry timestamp NOT NULL, CONSTRAINT session_key PRIMARY KEY(session_key) );

will be activated with these settings in app.conf:

SessionOn = true SessionProvider = postgresql SessionSavePath = "user=a password=b dbname=c sslmode=disable" SessionName = session

Usage: import(

_ ""


func init() {
	globalSessions, _ = session.NewManager("postgresql", ``{"cookieName":"gosessionid","gclifetime":3600,"ProviderConfig":"user=pqgotest dbname=pqgotest sslmode=verify-full"}``)
	go globalSessions.GC()

more docs:


Package Files


type Provider Uses

type Provider postgres.Provider

Provider postgresql session provider

func (*Provider) SessionAll Uses

func (mp *Provider) SessionAll() int

SessionAll count values in postgresql session

func (*Provider) SessionDestroy Uses

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

SessionDestroy delete postgresql session by sid

func (*Provider) SessionExist Uses

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

SessionExist check postgresql session exist

func (*Provider) SessionGC Uses

func (mp *Provider) SessionGC()

SessionGC delete expired values in postgresql session

func (*Provider) SessionInit Uses

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

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

func (*Provider) SessionRead Uses

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

SessionRead get postgresql session by sid

func (*Provider) SessionRegenerate Uses

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

SessionRegenerate generate new sid for postgresql session

type SessionStore Uses

type SessionStore postgres.SessionStore

SessionStore postgresql session store

func (*SessionStore) Delete Uses

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

Delete value in postgresql session

func (*SessionStore) Flush Uses

func (st *SessionStore) Flush() error

Flush clear all values in postgresql session

func (*SessionStore) Get Uses

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

Get value from postgresql session

func (*SessionStore) SessionID Uses

func (st *SessionStore) SessionID() string

SessionID get session id of this postgresql session store

func (*SessionStore) SessionRelease Uses

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

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

func (*SessionStore) Set Uses

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

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

Package postgres imports 5 packages (graph). Updated 2020-11-07. Refresh now. Tools for package owners.