0

I have an angular 7 application

www.myapp1.com

i have another application for login authentication.

www.myauthapp.com

When ever i send login request my myauthapp will process request and saves some details in cookie. So my doubt is how can i read these cookie from my angular application myapp1

i have tried so many examples from google here it is link.

Pranav MS
  • 2,235
  • 2
  • 23
  • 50
  • 1
    When you tried the approach, what error you were getting? – KiraAG Jun 27 '19 at 05:04
  • You can access the cookies with plain js like `allCookies = document.cookie;`. Check out the [documentation](https://developer.mozilla.org/en-US/docs/Web/API/Document/cookie) or this [post on stackoverflow](https://stackoverflow.com/questions/14573223/set-cookie-and-get-cookie-with-javascript), – riorudo Jun 27 '19 at 05:35
  • @riorudo This is in java script. How can i get it in Typescript in angular 7 – Pranav MS Jun 27 '19 at 06:02
  • @Pranav MS if you take a look at the [source code](https://github.com/salemdar/angular2-cookie/blob/master/src/services/cookies.service.ts) of the example you posted, a similar method with plain js was used within the cookieService. – riorudo Jun 27 '19 at 09:26

1 Answers1

0

I guess that is not possible for accessing cookie of different site. You should set cookie from myapp1 and then only access via myapp1.

Or use localstorage too.

Hari Babu
  • 16
  • 4