Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error in modifying cookie and session validity (Driver:redis.Radix()) [BUG] #1553

Closed
1819997197 opened this issue Jul 8, 2020 · 1 comment

Comments

@1819997197
Copy link
Contributor

problem: Error in modifying cookie and session validity (Driver:redis.Radix())

Use example:
func main() {
db := redis.New(redis.Config{
Network: "tcp",
Addr: "10.11.0.116:6379",
Timeout: time.Duration(30) * time.Second,
MaxActive: 10,
Password: "",
Database: "",
Prefix: "web:",
Delim: "-",
Driver: redis.Radix(), // redis.Radix() can be used instead.
})
// Close connection when control+C/cmd+C
iris.RegisterOnInterrupt(func() {
db.Close()
})

defer db.Close() // close the database connection if application errored.

sess := sessions.New(sessions.Config{
	Cookie:       "sessionscookieid",
	Expires:      10 * time.Minute, // defaults 10 * time.Minute,
	AllowReclaim: true,
})
sess.UseDatabase(db)
app := iris.New()

app.Get("/set", func(ctx iris.Context) {
	s := sess.Start(ctx) //iris.CookieExpires(expire)
	s.Set("name", "iris")
	err := sess.UpdateExpiration(ctx, 30*time.Minute)  //update 30 * time.Minute
	fmt.Println("sess.UpdateExpiration err: ", err)

	// test if set here
	ctx.Writef("All ok session value of the 'name' is: %s", s.GetString("name"))
})

app.Run(iris.Addr(":50050"), iris.WithoutServerError(iris.ErrServerClosed))
}

error info:
unable to update expiration, the key 'web:479a233d-a1d5-4a71-9cd7-1c5dde707354' was stored without ttl.

error file path:
github.com/kataras/iris/v12@v12.1.8/sessions/sessiondb/redis/driver_radix.go:169

update:
func (r *RadixDriver) updateTTLConn(key string, newSecondsLifeTime int64) error {
var reply int
//err := r.pool.Do(radix.FlatCmd(&reply, "EXPIRE", r.Config.Prefix+key, newSecondsLifeTime))
err := r.pool.Do(radix.FlatCmd(&reply, "EXPIRE", key, newSecondsLifeTime))
if err != nil {
return err
}
// ......

return nil

}

@kataras
Copy link
Owner

kataras commented Jul 8, 2020

@1819997197 did you try with master branch? I think that's already fixed. Just go get -u github.com/kataras/iris/v12@master in your project's path and re-run the application.

@kataras kataras added this to the v12.2.0 milestone Jul 19, 2020
kataras added a commit that referenced this issue Jul 26, 2020
Former-commit-id: 5cb64a4121a664d5066312d385ebd36bb05151ce
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants