kokolegorille
Read http only cookie server side
Hello everyone,
I am trying to read a cookie I put on the connection after login. I set it like this…
defp put_refresh_cookie(conn, token) do
conn
|> put_resp_cookie("refresh", token, sign: true, http_only: true, secure: true, max_age: 604800)
# |> put_resp_cookie("refresh", token, sign: false, http_only: true, secure: true, max_age: 604800)
end
and I try to read it back in a refresh action of an API controller with…
refresh_cookie = conn.req_cookies["refresh"]
If I use sign: false in put_resp_cookie, I can read it back without problem. With sign: true, the value is not equivalent
How can I read it back when using sign: true?
Thanks in advance
Marked As Solved
al2o3cr
The trick is mentioned in the docs for put_resp_cookie - the corresponding fetch_cookies call needs to specify which cookies are signed/encrypted.
For instance, here’s a spot that does it in phx.gen.auth’s code:
2
Last Post!
kokolegorille
I need to get the cookie like this
refresh_cookie = conn.cookies["refresh"]
and not like this…
refresh_cookie = conn.req_cookies["refresh"]
I thought it would be the same, but it’s not.
Thank You for the help
0
Popular in Questions
I have seen a lot of code which picks the first element from a list using Enum.at(0) instead of List.first. Is there a reason why people ...
New
Hi guys, i’m new in the Elixir world, and i have to say, that i love it!
i’m having some problem to understand anonymous functions with ...
New
Hi there,
I am working with Ecto-Postgresql and I need to call all of the records from a specific table but the table has 40,000 records...
New
In asking this question I am more interested about the expressiveness of the language itself and less concerned about the availability of...
New
i’m a new one to elixir
which editor can i use
vs code? or atom?
Thanks! :smiley:
New
I am trying to run a deploy with docker and I successfully runned with this command:
docker build -t romenigld/blog-prod .
but when I t...
New
In the code below, if the create action is not set to accept “extra_key” as an input, it errors out with a message shown above. Is there ...
New
Other popular topics
Original source of discussion: This topic on the Pragmatic Programmers’ Functional Web Development with Elixir, OTP, and Phoenix forum.
...
New
For some reason my phoenix channels are working for me in my local dev environment, but as soon as I deploy via Docker, I get a 403 error...
New
Hi everyone!
I need implement if…else if…else condition from my elixir code, and anymore of this control flow structures not work proper...
New
If I have a post route which an argument:
post /my_post_route/:my_param1, MyController.my_post_handler
How would get the post params ...
New
I am VERY much an elixir newbie. I have taken one elixir course and one phoenix course on Udemy. During that course, I saw the instructor...
New
I have a server on AWS, and was running a load test using artillery. When looking at the Phoenix dashboard I see the Ports going to 100% ...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #elixirconf-us
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #metaprogramming
- #security
- #hex









