Web Development Exercise 9-2

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

_x000D_
_x000D_
_x000D_
_x000D_

"Order a similar paper and get 100% plagiarism free, professional written paper now!"

Order Now