Today I learnt about the Set-Cookie header in HTTP. As per the documentation:

The Set-Cookie HTTP response header is used to send cookies from the server to the user agent, so the user agent can send them back to the server later.

I have found that this is a fantastic way to set a cookie when using server-rendered websites.