<p>Fellow gophers, I have a very strange issue. I've built a web application that uses the gorilla toolkit and secure cookie for authentication. The authentication is simple. If the user goes to "/" without a valid session, the user is redirected to "/login". Login does a POST and generates a session if the authentication is successful, then sends an instruction to the client to redirect to "/" (instructions are JSON objects written to the response writer using the json package). </p>
<p>Here'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'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've tried the app in chrome, firefox and even IE. I've also tested using postman which stated "no cookies were sent by the server." 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'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
- 请尽量让自己的回复能够对别人有帮助
- 支持 Markdown 格式, **粗体**、~~删除线~~、
`单行代码`
- 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
- 图片支持拖拽、截图粘贴等方式上传