How long a cookie stays in the browser varies and largely has to do with what it’s used for. Session cookies last as long as the browser is open and are then automatically deleted. However, persistent cookies can stay after the browser is closed and are typically used for remembering user preferences.
Browsers can also set limits on how long a cookie can last. For instance, Google Chrome requires that a cookie can’t expire more than 400 days from the time it was set.