Question Description
Im studying and need help with a Computer Science question to help me learn.
Exercise 9-2 In this project, you will create a cookies program that stores the date and time of a users last visit. 1. Create a new document in your text editor and type the declaration, element, header information, and element. Use the strict DTD and Last Visit as the content of the element. 2. Add the following script section above the declaration: 3. Add the following if...else statement to the script sec- tion to assign a value to the $LastVisit variable. If the $_COOKIE['lastVisit'] variable is set, the date and time of the last visit is assigned to the $LastVisit variable. Otherwise, the variable is assigned a value of This is your ?rst visit! if (isset($_COOKIE['lastVisit'])) $LastVisit = "Your last visit was on " . $_COOKIE['lastVisit']; else $LastVisit = "This is your first visit!n"; 4. Add the following statement to the end of the script sec- tion. The statement uses the date() function with the setcookie() function to assign the date to the $LastVisit variable. Notice that the cookie is set to expire in one year. setcookie("lastVisit", date("F j, Y, g:i a"), time()+60*60*24*365); 5. To the document body, add the following output directive, which displays the value of the $LastVisit variable: 6. Save the document as LastVisit.php in the Projects direc- tory for Chapter 9, and then close the document in your text editor.7. Open the LastVisit.php ?le in your Web browser by enter- ing the following URL: http:///PHP_Projects/ Chapter.09/Projects/LastVisit.php. The ?rst time you open the page, you should see This is your ?rst visit! in the browser window. Reload the Web page; you should see the date and time in the browser window. 8. Close your Web browser window.