获取Session中的UserId时,空指针异常
golango-cn opened this issue · 2 comments
golango-cn commented
这行代码内部从sessions.CookieStore中获取session,当SessionID为空时,会生成新的SessionID,此时session的Values是一个空对象map[interface{}]interface{},在sess.Values["userId"].(int64)这句代码处报空指针异常。
这里的userId是在哪一步写入到sessions.CookieStore中的,请求时cookis中只有remember-me-token这个参数,没看明白userId的获取方式,是我哪一步忘记写了么,请指教。
printfcoder commented
在user-web服务中的Login方法. 在调用Login方法后才能请求其它Web方法,这样才能通过验证
golango-cn commented
不好意思,没注意这里。