Making a cookie with vapor

Hello. I'm new to Vapor 4 and Swift and I'm trying to figure out how to set a cookie to my response. I noticed on the vapor 4 docs that all they mention are session cookies, but I'm just trying to create a refresh token cookie with properties HttpOnly Secure and Max-Age . When I looked at past versions, there's some mention of a class Cookie but I don't see any references to that now nor am I sure what library they're using. Thank you!

Hi! You can create your own cookie and assign it to a Response like so:

let cookie = HTTPCookies.Value(string: "some-value", expires: expiryDate, maxAge: 300, isSecure: false, isHTTPOnly: true, sameSite: HTTPCookies.SameSitePolicy.none)
response.cookies["cookie-name"] = cookie
Terms of Service

Privacy Policy

Cookie Policy