What's Changed
-
Store API Changes
- The Store no longer generates the session ID; it is now passed on to the
Create()
method. - Introduced a new method,
SetMulti()
, to set key-value pairs. - The
Commit()
method has been removed. BothSet()
andSetMulti()
methods now apply changes immediately to the store. - The
Clear()
method now only empties the session. - A new method,
Destroy()
, has been added to delete the session.
- The Store no longer generates the session ID; it is now passed on to the
-
Session Manager API Changes
- Cookie-related options have been moved to
Options.Cookie
. - The
RegisterSetCookie
andRegisterGetCookie
methods have been removed and replaced withSetCookieHooks
, which takes get and set cookie callbacks respectively. - The
Options.DisableAutoSet
option has been removed and replaced withOptions.EnableAutoCreate
. A new session will not be created automatically unlessOptions.EnableAutoCreate
is set totrue
. - Added a new method,
manager.NewSession()
, to create a new session. Since sessions are not created automatically onAcquire()
ifOptions.EnableAutoCreate
is not set totrue
. - The
Acquire()
method now takes context as the first parameter instead of the last. - Introduced a new method,
SetCookieHooks
, which can be used to override session ID generation and validation. By default, a 32-character alphanumeric ID is generated, and the length can be changed usingOptions.SessionIDLength
.
- Cookie-related options have been moved to
-
Session API Changes
- Removed the
ErrorFieldNotFound
error. The store returns anil
value if a field is not found. If chained with type assertion helpers, thenErrNil
will be raised when the value isnil
. - The
LoadValues()
andResetValues()
methods have been removed and replaced withCache()
andResetCache()
methods. Unlike the previous version, all mutations are saved in the cache ifCache()
is called. - The
Clear()
method no longer clears the cookie and only empties the session. Use the newDestroy()
method to delete the session and clear the cookie.
- Removed the
Full Changelog: v2.0.1...v3.0.0