Practice Quiz

Intro to PHP


This practice quiz is posted to help you prepare for the final exam. The questions here are similar to those that will be on the exam. (Some of them may actually be on the exam.) Mark your selections using the radio buttons. Answers are shown by clicking the button at the bottom of the page.

  1. The reason HTTP cookies were invented was
    1. to provide continuity between visits to pages on a web site
    2. to enable online merchants to track users' shopping preferences
    3. to allow web servers to store data on users' computers, reducing their own storage requirements
    4. to provide a means for installing software on users' computers
  2. Which statement about HTTP cookies in JavaScript is false?
    1. Cookies with the httponly attribute cannot be accessed via JavaScript on the client.
    2. The document.cookie object holds all the cookies that are valid for the document.
    3. Cookies can be set by assigning them to document.cookie as a string.
    4. The Cookie object provides a W3C standard API for working with cookies.
  3. If a cookie is set without an expiration date, then
    1. the cookie is rejected by the client browser.
    2. it expires in one month.
    3. it expires when the browser is closed.
    4. it never expires.
  4. The session_start() call for a PHP session
    1. is only needed on the page initially visited.
    2. goes into a JavaScript function that runs at page load.
    3. always starts a fresh session.
    4. must be placed at the top of every page participating in the session.
  5. A proper use of HTTP cookies is
    1. to store credit-card numbers or other sensitive information in encrypted form.
    2. to store all visitor information in the cookie, so it is not kept on the server where it could be hacked.
    3. to store a unique user ID or session ID, used to key into a database where all other information about the visitor is stored.
    4. all of the above.