PHP PARTNERING FOR COOKIES


TASK

1.  I'm assuming you're in lab with your p4 teammates, so why don't you
do this together, too.

2.  There's this thing called a cookie.  It's called that, I imagine,
because it stores things on your computer, and it's sort of fun to
imagine that it's storing cookies in your cookie jar.  But what it's
really storing is usually shopping cart contents, site preferences
such as "remember that I am from the U.S.", and a unique ID so it can
say "hey, I remember you" when you return to the site.

3.  My brother wrote this whole paper about the ethics of setting cookies.
Ha.  There are so many other ways to violate your privacy that it's just
a joke to malign cookies.  Cookies turn out to be one of the most benign
things out there.  If you don't want to be identified as a "returner"
to a site, just go to your cookie jar (search for "cookie" on your computer)
and wipe out the file.

4.  Cookies remain useful for web programmers using php for the first time
who don't know how to read and write to files and want a simple way of
changing the state (e.g., putting things in shopping carts).  THIS MAY BE
YOU!  You might even want to design your p4 to use a cart... that would be
a good sign that you deserve a good grade even though it was not
explicitly part of the assignment.  Or you could resign yourselves to the
dreaded A-/B+ borderline.

5.  Have a look at this cool program I just wrote:

	<?
	  setcookie("antigone", rand(0,100))
	?>

	Hello.  Unbeknownst to you, I am storing information on
	your computer.

You can go to www.php.net/rand to see what the rand function does.
Or www.php.net/setcookie.  Good reading.  PHP is easy, right?

Put this on the server as set.php and access it with the browser.

6.  How can you prove that it set the cookie?  Well, you could look
for the cookie file, modified in the past minute.  You might try that.

Or you could run this program:

	The value of antigone in your cookie jar is:
	<br>
	<?
	  print $_COOKIE["antigone"]
	?>

by saving it as read.php on the server and accessing it with your
browser.  And now you can see what is stored on YOUR computer.

Try change the program so it prings "antigone did her thing "xxx" times
today." where xxx is the value of the cookie.

7.  Keep accessing read.php.  Why doesn't the value ever change?

You have to re-run the set.php program in order to get a new value
stored on your computer.  Do that.  Now read the new value.  Fun stuff.

8.  That's it!  You can now work on your p4's.