0

How can I make a logged-in-check via an external call (external domain) to a main server? Should be a js client-server call.

In other words domain1.com makes a client-server call to the main-domain.com to check if the user is already logged-in in main-domain.com

Ardit
  • 98
  • 1
  • 3
  • 16

3 Answers3

1

What you are looking for is crossdomain request with cookies, this requires that you must specify some header output on the domains, you can find more information @ this stackoverflow link.

You'll need some kind of handler on the main domain that can start the session, verify that it has the necessary session data that says its logged in and return true/false for the caller.

DevionNL
  • 142
  • 1
  • 12
1

According to me, easiest way is to maintain a flag in your main domain. So what you need to do is.

  1. Add one field in users table, let's say isLoggedIn

  2. Create an API which return true or false when you make a call from domain1.com

  3. Handle data based on the result of the API.

Nikhil G
  • 2,096
  • 14
  • 18
1

There are two ways you can:

  • Use simply api token authentication on main domain.
  • Setup OAuth on main domain.
Raza Mehdi
  • 923
  • 5
  • 7