Ad

Can I Store An Access Cookie In A Laravel Session?

- 1 answer

I am working with a remote API that is normally accessed directly via JavaScript. In the normal flow, The user authenticates by sending Auth headers and in return is granted a cookie.

What I am trying to do is send auth headers from a laravel app, authenticate in the app controller, and provide API access through laravel controller functions.

I was hoping this would be as simple as authenticating and sending my subsequent API calls, hoping that the cookie given to the PHP server would continue to grant authentication.

Well that doesn't work and thats fine, but now I am thinking that I need to store my access cookie in the Session, and send it in the headers for future API calls.

Will this work/how can I go about this? My supervisors don't want to implement OAuth type tokens on the remote server and to me that seems like the best route, so I am a bit stuck.

Ad

Answer

Cookies cannot be shared across multiple hosts. The cookie (on the client) is only valid for path which set it.

Ad
source: stackoverflow.com
Ad