Fordham, the Jesuit University of New York

CISC 3300 L01

Internet & Web Programming

Spring, 2015

Dr. Robert K. Moniot

back Back to course home page

Web Project 9: Cookies

Assigned: Monday, March 30
Due date: Thursday, April 9
Points: 5

The aim of this project is for you to get familiar with setting and reading cookies in PHP.

Create a new page for this project. Name the new page project9.php. When first visited, this page sets a cookie (using PHP, not JavaScript). The name of the cookie is to be your username, e.g. if your erdos account is janeuser, the cookie name is 'janeuser'. (This is to keep all the cookies my web browser is going to be collecting as I grade this project distinct.) Create a permanent, not session, cookie. Give the cookie an expiration date 1 week in the future.

Set the value of the cookie to the integer timestamp of the visit. Obtain this using the PHP time() function. (This integer is the number of seconds that have elapsed since a standard date called “the epoch.”)

On later visits, if the cookie is set, its value is printed in a human-friendly format. You can use the PHP date() function for this. (Feel free to use one of the predefined string constants that specify standard formats.) Include appropriate text such as “your last visit was:”. The cookie is then updated to the timestamp of the new visit.

Remember that when the cookie is first set, you will need to reload the page in order for it to appear to the PHP script. This page is closer to the set-cookie example than the welcome example from class. In particular, it does not need a major division into three parts.

Note: Your project page must pass the W3C validator with no more than the unavoidable warning about the experimental HTML5 conformance checker.