php-proxy icon indicating copy to clipboard operation
php-proxy copied to clipboard

how can we handle cookies

Open bwl21 opened this issue 1 year ago • 1 comments

I try to use this proxy to work around CORS issues.

The objective is to implement a "facade" for a given "service". so the facade should set cookies just as "service" does. Eventually a user should be able to use "facade" instead of "service".

If User logs in to "service" the cookies from "service" should be delivered in any subsequent call.

So if user logs in to "service" via "facade" the "service"-cookies should be set in the browser (thereby appearing as "facade" cookies). In a subsequent call the "facade" cookies should be forwarded to "service".

"facade" and "service" of course run on different servers. I have no access to the installation of "service".

How could I achieve this?

bwl21 avatar Jul 16 '22 17:07 bwl21

Hi, if I understand your use case correctly the flow is: Your app calls facade (proxy) Facade calls the service Service responds with "set-cookie" header having service domain in the header value Facade responds with "set-cookie" header having facade domain in the header value

At this moment this should be possible, the script already automatically translates cookies so they look like they are set via the proxy. https://github.com/zounar/php-proxy/blob/master/Proxy.php#L405

There's nothing extra needed. Please let me know if it works for you or not.

zounar avatar Jul 19 '22 08:07 zounar