google-chromehttpcookies

Cookie not sent, cookies tab in chrome not visible


I have a domain bar.local (local development stage) And another backend at foo.bar.local

At a request to bar.local I set a cookie (on the server, in PHP)

$success = setcookie(
    'amc-jwt'
    $accessTokenString,       // cookie value
    time() + 60*60*24*30,           
    '/',
    'bar.local',
    true,                     // secure
    true                      // http-only
);

After the request, I can see the cookie in the Application Tab of the chrome dev tools under cookies.

The problems

On other requests to bar.local I see the cookies tab.

Any idea what the problem is or how to debug this?


Solution

  • My problem was in the code that does the request. It is angular and I use the angular http client.

    With this http client you have to activate cookie sending via

    this.http.post(
        this.spacesApiUrl, bodyData,
        {
            withCredentials: true   // adds cookies
        }
    )
    

    So if you have the same problem, chances are your code (the library you use) does not add the cookies. And as no cookies are added, no cookies tab is shown in chrome.