Tide provides a middleware pattern for handling cookies. When using cookie management, you can retrieve cookies from an incoming Request and set new cookies on an outgoing Response using insert_cookie.
To retrieve a cookie, use req.cookie("name"). To set a cookie, create a Cookie object and use res.insert_cookie(cookie).
# use tide::{Request, Response, StatusCode};
# use tide::http::cookies::Cookie;
# use tide::prelude::*;
let mut app = tide::Server::new();
// Retrieve a cookie from a request
app.at("/get").get(|req: Request<()>| async move {
Ok(req.cookie("testCookie").unwrap().value().to_string())
});
// Set a cookie in a response
app.at("/set").get(|_| async {
let mut res = Response::new(StatusCode::Ok);
res.insert_cookie(Cookie::new("testCookie", "NewCookieValue"));
Ok(res)
});