1

Good afternoon, I have a problem that I would like to get your help with if it were possible.

First of all I would like to mention that I am using Angular with TypeScript. I am trying to make a kind of single sign on of several websites in a single application and I am having some problems when it comes to redirecting to the desired website. All websites that I am trying to sign in cannot be changed and I can only make changes to the application I am developing. On the client side, I make a request to the API (NodeJS) that performs the authentication on the intended website and returns an authentication cookie to the client.

So far so good, it's working perfectly. The problem arises when I need to open a new browser tab and pass the authentication cookie I received. When opening a new tab I am forwarding to the page after login and I need the cookie for that task.

I tried to set the cookie in the browser to a different domain but without success. Can someone help me, whether it is trying to find a solution or indicating a possible different way to solve the problem? I would like to mention that the domain of all websites are different from each other and different from the application I am developing.

Thank you in advance to anyone who can help or direct me to the solution and I apologize if I did not understand perfectly what I want. Any doubts tell me that I try to explain better.

Regards, André Pinto

2 Answers2

0

From frontend you cannot set a cookie of another domain, but what you can do is to have a php page, which sets cookie of another domain or have a backend redirect. you can use this article for detailed information :-

https://subinsb.com/set-same-cookie-on-different-domains/

On reference link more :- Setting cookie for different domain from javascript

Aakash Garg
  • 10,649
  • 2
  • 7
  • 25
0

As mentioned above you won't be able to achieve this with cookies; being able to set cookies for other domains would be a massive security issue.

If you control the other website and have access to the backend, then your backend can handshake to identify the user. Otherwise you could look at using a querystring redirection to authenticate the user.

All the best.

Croot
  • 331
  • 1
  • 10
  • Thanks for the tip, I will first try to find solutions to make all the changes in my application because I do not have access to others that I intend to put the cookie on. – André Pinto Jun 03 '20 at 12:55