This is a pure Go session store implementation. A session manager is use to create and remove sessions, add, edit and remove values bound to a session. This can be used to contextualize sessions, e.g. for logically separating user login and admin login or shoping carts or ....
- You should have a basic knowledge of how sessions and cookies work.
As initialization, create a new SessionManager with a supplied session cookie name:
var sessMgr *sessionstore.SessionManager = sessionstore.NewManager("MY_SESSION_NAME")
Then, you can create a Session with a supplied validity, e.g. 30 days:
sess, err := sessMgr.CreateSession(time.Now().Add(30 * 24 * time.Hour))
Retrieve a Session by ID (typically obtained from a session cookie):
sess, err := sessMgr.GetSession("123abc")
Remove a Session by ID (when a user logs out):
err := sessMgr.RemoveSession("123abc")
Add or set a value to a session (not SessionManager!) and get it:
sess.SetVar("key", "value")
val, exists := sess.GetVar("key")
coming soon