Setting a cookie from ControllerBase?

I need an 'unique' identifier on many controllers, so I thought i'd do something like this:

class ControllerBase extends Controller
    public function initialize() {
        if (!$this->cookies->has('identifier')) {
            $this->cookies->set('identifier', uniqid(mt_rand(), true), time() + 15 * 86400);

It doesn't seem to work however? :/


Check the output in the Chrome Developer Console to see it the cookie was not sent.