File: cookies.php

package info (click to toggle)
php4 4.0.3pl1-0potato3
  • links: PTS
  • area: main
  • in suites: potato
  • size: 15,168 kB
  • ctags: 20,556
  • sloc: ansic: 155,237; php: 10,827; sh: 9,608; yacc: 1,874; lex: 1,742; makefile: 788; java: 424; awk: 359; cpp: 335; perl: 181; xml: 57
file content (41 lines) | stat: -rw-r--r-- 981 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<html>
<body bgcolor="white">
<head>
<title>Cookies Example</title>
</head>
<body>
<h3>Cookies Example</h3>

<?
  $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:<br>\n";

    foreach ($cookies as $cookie) {
      echo "Cookie Name: $cookie->name<br>Cookie value: $cookie->value<br>\n";
    }
  }

  // set a cookie

  if ($cookieName) {
    $response->addCookie(new Java("javax.servlet.http.Cookie", $cookieName, $cookieValue));
    echo "<p>You just sent the following cookie to your browser:<br>\n";
    echo "Name: $cookieName<br>Value: $cookieValue<P>\n";
  }

?>
<P>
Create a cookie to send to your browser<br>
<form action="<?PHP echo $PHP_SELF ?>" method=POST>
Name:  <input type=text length=20 name=cookieName><br>
Value:  <input type=text length=20 name=cookieValue><br>
<input type=submit></form>
</body>
</html>