How to implement S-SSO cross domain

The problem for me was:

I was using prompt=login option for loginWithRedirect. This will always show the login prompt even if there is a valid session on the server. Just removed prompt=login option and it works now.