Home >Backend Development >PHP Tutorial >PHP的COOKIE问题

PHP的COOKIE问题

WBOY
WBOYOriginal
2016-06-06 20:29:161255browse

在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>
Statement:
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