fukamachi / ningle

Super micro framework for Common Lisp
http://8arrow.org/ningle/
273 stars 25 forks source link

How do I properly set cookies? #43

Closed nathanvy closed 12 months ago

nathanvy commented 1 year ago

I can set cookies using the :headers property in ningle:*response*, but if I try to use:set-cookies` which is also part of the response struct, it just silently fails. I can see in the browser console no cookies are set:

(setf (lack.response:response-set-cookies ningle:*response*)
                "foobar=barbaz")
Screenshot 2023-08-29 at 11 24 54 PM

What is the correct way to set cookies?

fukamachi commented 12 months ago

response-set-cookies must be a property list that has a key as the name and a value as a property list containing :value, :domain, :path, :expires, :secure, :httponly, and :samesite.

ex. ("foobar" (:value "barbaz"))

Here is the code of Lack.Response: https://github.com/fukamachi/lack/blob/master/src/response.lisp#L44

nathanvy commented 12 months ago

Thanks. I had found the code previously, but reading it did not provide me with any clarity. I appreciate the response.