In the examples you use authentication is handled externally, which (like @foozy already said) is also known as single sign-on (SSO). So they don't use a session variable, but some kind of Authentication token (often in the headers stored at the wrongly named and because of that a bit confusing "Authorization" tag; it should have been "Authentication" tag).
The same token is used for authentication at different hosts/applications, they validate the token at the service that supplied the Authentication token. If validation succeeds the authentication is successful.
Read more on the topic here
To get to your question: in sub-domains it would indeed be possible to share the session. If you have troubles getting that going there is a lot of information available on Stack-Overflow on the topic like for example here