Gmail Login – Why Gmail Login Redirects Through YouTube

gmailgoogle

For a while I've noticed that Google logins (or, at least, GMail logins) always redirect through to "youtube.com" Is Google handling all logins from youtube.com? If so, why?

(wasn't sure if I should post this on webapps or superuser, so feel free to move this or tell me to move this to the appropriate site if necessary)

Best Answer

When you log into a Google site like GMail, Google also logs you into all your various accounts Google accounts - such as YouTube. In order to be logged into a site, Google sets a cookie in your browser.

This is fine for most of their properties which are on the *.google.com domain (mail.google.com, docs.google.com, etc). However a website can only set and read a cookie for it's own domain - google.com can't set a cookie for youtube.com. To get around this, as part of the login process Google will redirect you through accounts.youtube.com to log you into YouTube - and typically your country specific domain if you are outside the US (e.g. I get logged into google.com.au as well).

The full login process is described in this SO answer, it dates from 2009 but most of it should still hold true.