1
0
mirror of https://github.com/kataras/iris.git synced 2025-12-24 05:17:03 +00:00

🌈 sessions were re-written, update to 4.0.0-alpha.2, read HISTORY.md

**Sessions were re-written **

- Developers can use more than one 'session database', at the same time,
to store the sessions
- Easy to develop a custom session database (only two functions are
required (Load & Update)), [learn
more](https://github.com/iris-contrib/sessiondb/blob/master/redis/database.go)
- Session databases are located
[here](https://github.com/iris-contrib/sessiondb), contributions are
welcome
- The only frontend deleted 'thing' is the: **config.Sessions.Provider**
- No need to register a database, the sessions works out-of-the-box
- No frontend/API changes except the
`context.Session().Set/Delete/Clear`, they doesn't return errors
anymore, btw they (errors) were always nil :)
- Examples (master branch) were updated.

```sh
$ go get github.com/iris-contrib/sessiondb/$DATABASE
```

```go
db := $DATABASE.New(configurationHere{})
iris.UseSessionDB(db)
```

> Note: Book is not updated yet, examples are up-to-date as always.
This commit is contained in:
Makis Maropoulos
2016-07-15 20:50:36 +03:00
parent af4df18ec4
commit 077984bd60
20 changed files with 733 additions and 1582 deletions

View File

@@ -5,11 +5,11 @@ import (
"io"
"time"
"github.com/kataras/iris/sessions/store"
"github.com/valyala/fasthttp"
)
type (
// IContext the interface for the iris/context
// Used mostly inside packages which shouldn't be import ,directly, the kataras/iris.
IContext interface {
@@ -71,7 +71,17 @@ type (
GetFlashes() map[string]string
GetFlash(string) (string, error)
SetFlash(string, string)
Session() store.IStore
Session() interface {
ID() string
Get(string) interface{}
GetString(key string) string
GetInt(key string) int
GetAll() map[string]interface{}
VisitAll(cb func(k string, v interface{}))
Set(string, interface{})
Delete(string)
Clear()
}
SessionDestroy()
Log(string, ...interface{})
Reset(*fasthttp.RequestCtx)