<p>Hello I am using beego to create an API, and I am using gorillla for the session as I had problems with beego's session. Now this is working well on localhost but cookies are not sent on the deployed version on heroku. Here is how I set the cookies in a controller:
session, _ := store.Get(c.Ctx.Request, "session") // c is the controller
session.Values["id"] = user.Id </p>
<hr/>**评论:**<br/><br/>Justinsaccount: <pre><pre><code>session, _ := store.Get(c.Ctx.Request, "session")
</code></pre>
<p>Have you tried not ignoring the error?</p></pre>frebb: <pre><p>I haven't used Gorilla sessions but I'm curious about your issues with Beego sessions. I've used just that portion of Beego in a few projects and didn't have any issues. I didn't want everything stored in a cookie which I believe is the Gorilla default.</p></pre>moar55: <pre><p>I am trying to investigate if the problem happens after it is sent from the beego server (heroku discards the cookie), or for some reason the deployed beego app doesn't write the cookie to the responsewriter. I am trying to see how I can print the contents of the responsewriter before the json data is served.</p></pre>frebb: <pre><p>With Beego/session, once you have a <code>session.Manager</code>, you just call <code>sess, err := sessionManager.SessionStart(w, r)</code> and it will either get the session associated with a cookie in the request (<code>r</code>), or create a new session and set the cookie, which it does here: <a href="https://github.com/astaxie/beego/blob/master/session/session.go#L226" rel="nofollow">https://github.com/astaxie/beego/blob/master/session/session.go#L226</a></p>
<p>You'll want to check the error.</p></pre>
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889
- 请尽量让自己的回复能够对别人有帮助
- 支持 Markdown 格式, **粗体**、~~删除线~~、
`单行代码`
- 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
- 图片支持拖拽、截图粘贴等方式上传