I have subdomain front.test.local as frontend ngx-app and another subdomain back.test.local for the backend pure Drupal both on https - cookie-domain is set to '.test.local'. I need cookie because views resource with image thumbnails in private://. I trying to get a cookie on frontend after login response in a second request to custom post resource /custom/cookie again basic_auth. I adding a headers array

    $headers = ['Set-cookie'=>'sess_name=sess_id', 'test: name=value;'];

to return from post resource

    new ModifiedResourceResponse($data, 200, $headers);

The response headers seem the same every time: ["content-language", "cache-control", "content-type", "expires"] - no 'test', no cookies

Is it possible to set additional response headers, 'Set-cookie' or another? For now, I sending a sessName and sessID in this second response and frontend create a cookie - and this works fine, but it will be nice to set this cookie through a set-cookie header though.

edit2: improved workaround to skip doubled post with basic_auth (which produce 2 sessions) to one - gist to CustomLoginResource https://gist.github.com/svetlio/156ed32ecccbd38cfae32357a5d6093d return sessId&sessName alongside user id name roles but missing csrf_token , still missing Set-cookie header

  • Did you try to call PHP standard setcookie before returning your RessoureResponse? Sep 12 '18 at 11:14
  • Yes, I did, no difference in the result.
    – svetlio
    Sep 12 '18 at 11:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.