How to get/set cookies

I want to use http cookies for csrf, and the examples use the hidden fields.

How can I set cookies in the request, and read cookies in the response?

Thanks

// Set expires in past time and date
$app->cookie->set(‘test’, [
‘expires’ => date(‘Y-m-d H:i:s’, time() - 36000)
]);

// Modify response with cookies
$response = $response->withHeader(‘Set-Cookie’, $app->cookie->toHeaders());

$container[‘cookie’] = function($c){
$request = $c->get(‘request’);
return new \Slim\Http\Cookies($request->getCookieParams());
};

@rgeddes,Where exactly do you want to use Cookies??