Skip to content

jstemmer/sqlstore

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

sqlstore

SQL session store for the Gorilla web toolkit.

Work in progress, API may not be stable. Currently only supports the PostgreSQL dialect for either the stdlib database/sql package or the pgx driver.

GoDoc

Build Status

Usage

See the Gorilla toolkit sessions documentation on how to use the sessions package.

Get the package go get github.com/jstemmer/sqlstore and import github.com/jstemmer/sqlstore. Depending on which database implementation you want to use either import github.com/jstemmer/sqlstore/pgdb or github.com/jstemmer/sqlstore/pgxdb.

Call sqlstore.New() to create a new store and provide it with a database implementation and keyPairs. See the session.NewCookieStore documentation on how to use the keyPairs parameter.

For example:

store := sqlstore.New(pgdb.New(db), []byte("something-very-secret"))

Sessions are stored in a sessions table, which is assumed to exist. It should have the following schema:

CREATE TABLE sessions (
	id varchar(100) PRIMARY KEY,
	data bytea NOT NULL,
	created_at timestamp NOT NULL,
	updated_at timestamp NOT NULL
);

License

MIT, see LICENSE.

About

SQL session store for gorilla/sessions

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages