skip to Main Content

I am trying to set cookies using the Laravel HTTP client. I know Laravel uses guzzlehttp/guzzle library in the backend.

This is the error I am getting when I try to set the cookies using withOptions method.
enter image description here

Have anyone figured it out?

2

Answers


  1. Chosen as BEST ANSWER

    I utilized withCookies to include cookies with the request, although it's worth noting that this method isn't explicitly documented in the Laravel official documentation.

    Http::withCookies([
        '.ASPXAUTH' => $this->authCookie,
    ]
    

  2. It says the error is on line 35 and I can’t see that line but by the error my guess is you are passing the $this->auth_cookie as a cookie for your next request and that’s why the error says cookies must be an instance of CookieJarInterface

    the thing is when you call $authCookie->getValue() it returns the value of cookie which is string. If you want the $this->auth_cookie to be CookieJarInterface you should use this instead

    $this->auth_cookie = $authCookie;
    

    Hope it helps

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search