we have a login-protected web app built on one platform and a public-facing website built on another. The public site is meant to promote the web app, which people can access once they sign up.

Right now we have the public site under the root domain: ourwebapp.com, and the app under the subdomain app.ourwebapp.com. Login/authentication is handled by the app, but we want to streamline the user experience so that if they go to the root domain, but are logged-in to the app, then the root domain will redirect them to the app url.

An example is Netflix. If you are logged in with netflix and navigate to netflix.com, it will automatically redirect you to the login-protected movies.netflix.com url.

Is there a generic way to implement something like this?

网友答案:

if the authentication-storage (database?) is accessible by the your root-domain-page you may just do it by dirty scripting.
A cleaner solution is to implement an API for your app that is accessible via a webservice and use this on your webpage.