Skip to content

Instantly share code, notes, and snippets.

@sorentwo
Created February 14, 2015 16:23
Show Gist options
  • Save sorentwo/570a9376dabab94cbbe4 to your computer and use it in GitHub Desktop.
Save sorentwo/570a9376dabab94cbbe4 to your computer and use it in GitHub Desktop.
Cookies missing from view
# Form
<input type="hidden" name="_csrf_token" value="<%= @conn.req_cookies["_csrf_token"] %>"/>
<input type="hidden" name="_csrf_token" value="<%= csrf_token(@conn) %>"/>
# First input has the csrf_token value, second input value is blank
# Inside view module, IO.puts prints an empty map %{}
def csrf_token(conn) do
IO.puts inspect(conn.resp_cookies)
conn.resp_cookies["_csrf_token"]
end
# Inside the template all of the cookies are present
<p><%= inspect(@conn.req_cookies) %></p>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment