im working on a simple C++ HTTP server as a school project and I would like to add php support for it. Post and Get methods should not be a problem, but Im stuck on a cookies. I googled for long and couldnt find, how php handles cookies, where it gives the output for http server such as Apache or how does it work in global.
Any ideas how I could print this code:
<?php
setcookie("cookie[three]","cookiethree");
?>
to console so it can be read by my server and after some parsing(?) sent to a client?
Thanks guys
EDIT:
This is really close example to what I need, but when I execute the script it shows empty array..
http://php.net/manual/en/function.headers-list.php
php version:
PHP 5.3.6-13ubuntu3.2 with Suhosin-Patch (cli) (built: Oct 13 2011 23:09:42)
Copyright (c) 1997-2011 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2011 Zend Technologies
PHP get its superglobals variables (such as
Cookies) from the HTTP server itself. When you parse a client request, you must store every key/value pair in an appropriate container (anHTTPRequestclass perhaps).When interfacing your server with PHP you should write a module like apache does (
mod_php). To do this, you will have to write your own API for interfacing with the modules. This means for every module you’ll have (php, python …) you will have the same interface for your Inputs/Outputs.When writing such an API, you should define an easy way to pass all the superglobals variables PHP needs from the server. I’ve written my own HTTP server for the same purpose and the documentation of PHP is a little tricky about this point but you can inspire yourself from
PHP-CGI: there is aphp.exeor simplyphpcommand on Linux/Windows which can take arguments such as variables if my memory is good. Anyway, there are several ways to pass these arguments to php and I usedCGIfor my server.Hope that’ll help you.