A cookie is a small piece of data the server puts in your browser. The browser sends it back with every request — automatically, without you doing anything.
A session is the server reading that cookie to know who you are. The cookie stores your user ID (signed with a secret so it can't be forged), and the server looks up your user record each time.
The cookie is signed with a secret key. This means if someone tries to change the user ID inside the cookie, the signature won't match, and the server will reject it. You can't forge a session without knowing the secret.
This is why the COOKIE_SECRET environment variable matters — it's the key that keeps sessions trustworthy.