开发者

php setcookie vs Zend_Http_Cookie

Why this code not working, and how can I make it works like

setcookie('cookie_name','cookie_value');

The code that not create cookie:

$cookie开发者_StackOverflow中文版=new Zend_Http_Cookie('cookie_name','cookie_value','.google.com');

Or what difference between:

setcookie('cookie_name','cookie_value');

vs

$cookie=new Zend_Http_Cookie('cookie_name','cookie_value','.google.com');

Thanks


Zend_Http_Cookie is not for setting cookies, it is a companion class for Zend_Http_Client. Let's say you wanted to screen scape some content off a site but that content is only available if you are logged in. You could use Zend_Http_Client to post your credentials to the login form, the server would then send back a session cookie. You could then include this session cookie in a subsequent request to the page you want to scrape in order to simulate a logged in user viewing that page.

To set cookies in ZF you can just use the native PHP function, or possibly store the data in the session instead.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜