Beego: error whie creating new session

Created on 18 Mar 2017  ·  3Comments  ·  Source: astaxie/beego

Please answer these questions before submitting your issue. Thanks!

  1. What version of Go and beego are you using (bee version)? Go version - 1.8

  2. What operating system and processor architecture are you using (go env)?
    L-SNVJ0NCFFT-M:$ go env
    GOARCH="amd64"
    GOBIN=""
    GOEXE=""
    GOHOSTARCH="amd64"
    GOHOSTOS="darwin"
    GOOS="darwin"

  3. What did you do?
    Learning GO. Trying to create a new session
    In main,
    func init() {
    var globalSessions *session.Manager
    globalSessions, _ = session.NewManager("memory", {"cookieName":"gosessionid","gclifetime":3600})
    go globalSessions.GC()
    }

  4. What did you expect to see?
    Function newManager is expecting pointer to struct but we are passing string.

  5. What did you see instead?
    cannot use "{\"cookieName\":\"gosessionid\",\"gclifetime\":3600}" (type string) as type *session.ManagerConfig in argument to session.NewManager

Most helpful comment

Can u please try this...
This is how i set it up in my application...

sessionConfig := &session.ManagerConfig{
CookieName: "sessionid",
Gclifetime: 3600,
}
GlobalSessions, err = session.NewManager("memory", sessionConfig)
go GlobalSessions.GC()

Thanks...

All 3 comments

I am now getting:

multiple-value sessionkeeper.GlobalSessions.SessionStart() in single-value context

Can u please try this...
This is how i set it up in my application...

sessionConfig := &session.ManagerConfig{
CookieName: "sessionid",
Gclifetime: 3600,
}
GlobalSessions, err = session.NewManager("memory", sessionConfig)
go GlobalSessions.GC()

Thanks...

为何要修改这个?不明白。导致之前的代码编译不了。

Was this page helpful?
0 / 5 - 0 ratings