How to receive HTTP cookies from a web server in PHP?
Asked
Active
Viewed 359 times
0
-
Well, and then send them back to the server... I want to login in this way. Thanks. – Aug 01 '09 at 20:15
-
To clarify, do you want to recieve cookies from a remote webserver using PHP? Or are you simply refering to viewing cookies sent from a client browser? – Paul Dixon Aug 01 '09 at 20:24
-
0 How would I go about writing a simple PHP bot that could login in and recieve all the cookies sent by the server? ... and then send them back when required? Any suggestions would be appreciated. – Aug 01 '09 at 20:37
-
In that case, ignore the answers about $_COOKIE and setcookie, what you need is an HTTP client library, such as Zend_Http or HTTPRequest extension. – Paul Dixon Aug 01 '09 at 20:40
-
Yep, I'm googling for those. Thanks you. – Aug 01 '09 at 20:46
3 Answers
1
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
- 18,571
- 25
- 126
- 193
1
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
- 295,876
- 54
- 310
- 348
-3
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.

Quentin
- 914,110
- 126
- 1,211
- 1,335
-
Next time try to elaborate more. If he doesn't know the $_COOKIES superglobal then he's new to php. – the_drow Aug 01 '09 at 20:34
-
-