POST之后,PHP Guzzle跨域重定向带有会话数据

我正在尝试将用户注册从域#1 POST到域#2,并且在POST之后,我想将用户重定向到注册表单的域2的第二部分,在那里他们将填充其余信息。

我想知道应该怎么做。

这是我到目前为止得到的:

$url = '';

$jar    = new \GuzzleHttp\Cookie\CookieJar;
$client = new \Guzzle\Client;

$response = $client->request('POST','http://example.com/signup/page/one',[
    'cookies'   => $jar,'on_stats' => function (TransferStats $stats) use (&$url) {
        $url = (string) $stats->getEffectiveUri();
    },'multipart' => [
        [
            'name'     => 'first_name','contents' => 'John'
        ],[
            'name'     => 'last_name','contents' => 'snow'
        ]
    ]
]);

// Redirect to http://example.com/signup/page/two with response cookies/session data

header('Location:' . $url->__toString());

我试图在重定向之前从响应中写入cookie,但是失败了,因为它们仅保存到域#1中。

什么是正确的方法?

感谢您的帮助!

lgh19751228 回答:POST之后,PHP Guzzle跨域重定向带有会话数据

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/3156756.html

大家都在问