tags:

views:

94

answers:

3

How to receive HTTP cookies from a web server in PHP?

A: 

Just use the $_COOKIES superglobal

Well, and then send them back to the server... I want to login in this way

This suggests you want to know how to send them to the browser in the browser place.

See setcookie.

David Dorward
Next time try to elaborate more. If he doesn't know the $_COOKIES superglobal then he's new to php.
the_drow
A fast answer to a fast question seems fair to me.
toto
That's why I made $_COOKIES ... a link!
David Dorward
+1  A: 

Check the HTTPRequest class and take a look at the getCookies and setCookies functions. You can also use the $_COOKIES but it's much more low level.

the_drow
**@the_drow:** The PECL HTTP Extension is not bundled with PHP.
Andrew Moore
Oh, the docs didn't say it's an extension. Thanks.
the_drow
http://www.php.net/manual/en/http.install.php
Andrew Moore
Yeh just saw it myself, thanks.
the_drow
+1  A: 

I'm assuming that you want to interact with cookies from a remote webserver using PHP, rather than simply manipulating cookies from a client browser.

In that case, take a look at the Zend_Http and related classes in the Zend Framework. These let you perform HTTP requests with cookie persistence and a whole lot more besides.

Paul Dixon
Thanks. I'll check that out.