I have two different web application built with ASP.net MVC. This two application may not be running in the same server nor in the same domain.

I would like that if a user login in one of them, automatically should be login in the other. The same should work with logout.

Which do you think is the best solution? Do you know about some example code?

Thanks!

--- EDITED WITH MORE INFO ---

**Use case scenario:**

The user has the **web application A** opened on a tab, and at some point of the app there is a link that redirects the user to the **web application B**. If he is logged in on **A**, I would like to show him the full page, and if he is not, redirect him to the login form.

**Why I need to do it:**

Applications **A** and **B** are already built. Apparently, the only way of accessing **B** is clicking on the link located in **A**, that only is shown if you have previously logged. The problem is that if you know the URL of some page of **B** (are long and complex, but still) you can write it on the browser and access **B**, which it means a security problem.