PHP的COOKIE问题

WBOY
Release: 2016-06-06 20:29:16
Original
1223 people have browsed it

在b.example.com/store.php文件里使用CURL访问a.example.php/api.php文件,然后在a.example.php/api.php文件中设置cookie,但是设置失败,请大神解答一下为什么?

回复内容:

在b.example.com/store.php文件里使用CURL访问a.example.php/api.php文件,然后在a.example.php/api.php文件中设置cookie,但是设置失败,请大神解答一下为什么?

应该是curl时没有带上cookie导致

<code>        foreach ($_COOKIE as $k=>$v) {
            $cookie_str[] = $k.'='.$v;
        }
        $ch = curl_init(self::$_authUrl); 
        curl_setopt($ch,CURLOPT_COOKIE, implode('; ', $cookie_str)); //带上cookie</code>
Copy after login
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template