Cookies Example
Cookies Example
$cookies = $request->cookies;
// print out cookies
if (!current($cookies)) {
echo "Your browser isn't sending any cookies\n";
} else {
echo "Your browser is sending the following cookies:
\n";
foreach ($cookies as $cookie) {
echo "Cookie Name: $cookie->name
Cookie value: $cookie->value
\n";
}
}
// set a cookie
if ($cookieName) {
$response->addCookie(new Java("javax.servlet.http.Cookie", $cookieName, $cookieValue));
echo "You just sent the following cookie to your browser:
\n";
echo "Name: $cookieName
Value: $cookieValue
\n";
}
?>
Create a cookie to send to your browser