Setting cookie on an iframe website with ngx-cookie-service

1.6k views Asked by At

When I embed a youtube video for example in my angular component:

<iframe width="560" height="315" src="https://www.youtube.com/embed/w3jLJU7DT5E"></iframe></div>

I will get two entries in my Application/Storage/Cookies in Developer console:

enter image description here

One is my storage for my localhost and the other one is for iframe website.

Using ngx-cookie-service I tried to set a cookie into youtube section like this:

this.cookieService.set('cookie1', 'cookie1-value', null, null, 'https://youtube.com');

by setting only name, value and domain since .set is defined like this: set( name: string, value: string, expires?: number | Date, path?: string, domain?: string, secure?: boolean, sameSite?: 'Lax' | 'Strict' | 'None' ): void;

but it sets it into my https://localhost:4200.

Is it event possible to set it into https://youtube.com section?

1

There are 1 answers

0
cheshire On BEST ANSWER

The thing that I was trying to achieve is XSS or Cross-site scripting and it would be only possible to do if the domain in iframe was the same as the parent domain.