I am unable to set gorilla sessions on heroku.

xuanbao · · 505 次点击    
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
<p>Hello I am using beego to create an API, and I am using gorillla for the session as I had problems with beego&#39;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, &#34;session&#34;) // c is the controller session.Values[&#34;id&#34;] = user.Id </p> <hr/>**评论:**<br/><br/>Justinsaccount: <pre><pre><code>session, _ := store.Get(c.Ctx.Request, &#34;session&#34;) </code></pre> <p>Have you tried not ignoring the error?</p></pre>frebb: <pre><p>I haven&#39;t used Gorilla sessions but I&#39;m curious about your issues with Beego sessions. I&#39;ve used just that portion of Beego in a few projects and didn&#39;t have any issues. I didn&#39;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&#39;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&#39;ll want to check the error.</p></pre>

入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889

505 次点击  
加入收藏 微博
0 回复
暂无回复
添加一条新回复 (您需要 登录 后才能回复 没有账号 ?)
  • 请尽量让自己的回复能够对别人有帮助
  • 支持 Markdown 格式, **粗体**、~~删除线~~、`单行代码`
  • 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
  • 图片支持拖拽、截图粘贴等方式上传