I have a login component where after a successful response, a cookie is being set set-cookie: COOKIENAME=b4a70c42sd23d2f32defe61b772366e12b59; Path=/; HttpOnly
I'am trying to remove this cookie "Accessible to script No (HttpOnly)"
before each login, or in other words, I try to check if a cookie for this specific domain exists/still exists and then remove it.
I have been trying different ways to manage this, but it didn't work. First of all, I even can't get the cookie in browser console. It 's always empty or let's say no cookie.
`
...
import { CookieService } from 'ngx-cookie-service';
...
constructor(private cookieService: CookieService) {
console.log( `${ this.cookieService.get('cookieName')}` );
console.log( `browser.cookies.getAll() ==> ${ document.cookie.getAll() }`);
}`
Even when trying to get all browser cookies cookies.getAll()
, it's just empty because this is not for HTTP-Only cookies
.
I used ngx-cookie-service
, angular2-cookie
and ng2-cookies
with of course the call in the constructor()
etc. but always no value.
When I search via chrome settings for the specific domain cookie, I get all the cookies for that domain.
P.S. request goes from my localhost to an external domain (BackUp test server). The domain sets the cookie after response then on my browser (chrome).
I found a kind of similar question, but first there is no provided solution/answer and second it seems not exactly what I am trying to achieve. And there is also other question with an answer where it says that it's not possible to remove a http-only cookie outside the HTTP.
But if the cookie is a httpOnly cookie (a cookie with the httpOnly parameter set), you cannot read, change or delete it from outside of the HTTP.
Where am I going wrong? Is there a possibility to rest/remove the HTTP-Only cookie within the HTTP request, before sending the one with credentials?