Gorilla Session Cookie not sent to client

polaris · · 451 次点击    
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
<p>Fellow gophers, I have a very strange issue. I&#39;ve built a web application that uses the gorilla toolkit and secure cookie for authentication. The authentication is simple. If the user goes to &#34;/&#34; without a valid session, the user is redirected to &#34;/login&#34;. Login does a POST and generates a session if the authentication is successful, then sends an instruction to the client to redirect to &#34;/&#34; (instructions are JSON objects written to the response writer using the json package). </p> <p>Here&#39;s the strange part. If I start the server and run it on my development VM, it works as it should. However, when I deploy it to a production server, the login page constantly redirects back to login. I&#39;ve checked the client side and it shows that the login was successful and the login handler has executed correctly. However, I noticed that no session cookie was written. I&#39;ve tried the app in chrome, firefox and even IE. I&#39;ve also tested using postman which stated &#34;no cookies were sent by the server.&#34; This leads me to believe that there probably was a problem with either writing the session to the header, or with the session store. </p> <p>Any ideas what the cause might be? Here&#39;s the code: </p> <p><a href="http://pastebin.com/xXc5qaMQ" rel="nofollow">Login Handler</a></p> <p><a href="http://pastebin.com/DYHyqF6y" rel="nofollow">Sessions</a></p> <p><a href="http://pastebin.com/rnBHt73d" rel="nofollow">Session Store</a></p> <p>VM - Ubuntu 16.04 Production - RHEL 7.2</p> <hr/>**评论:**<br/><br/>Ajpennster: <pre><p>@fortyninezeronine that was it. I picked it up after inspecting the response from the ajax request and noticed the domain in the cookie. Thanks.</p></pre>

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

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