Merge pull request #121 from m6w6/issue-120
[m6w6/ext-http] / tests / helper / cookie2.inc
1 <?php
2
3 include "server.inc";
4
5 serve(function($client) {
6 $request = new http\Message($client, false);
7 $response = new http\Env\Response;
8 $old_cookies = new http\Cookie($request->getHeader("Cookie"));
9 $new_cookies = new http\Cookie;
10 $new_cookies->setCookie("temp", $old_cookies->getCookie("temp") ?: microtime(true));
11 $response->setCookie($new_cookies);
12 $new_cookies = new http\Cookie;
13 $new_cookies->setCookie("perm", $old_cookies->getCookie("perm") ?: microtime(true));
14 $new_cookies->setExpires(time()+3600);
15 $response->setCookie($new_cookies);
16 $response->send($client);
17 });