Cookies

Objectives

  • Use cookies to save data between sessions
  • Use functions in JavaScript
  • Use a custom library (cooklib.js)

Overview

This assignment involves cookies. Using a custom library, you have to create a page which looks different depending on whether a cookie is saved, and also allows the user to save a cookie and delete all of the cookies.

Images of assignment working

cookie assignment - saving view
Cookie assignment - saving view
cookie assignment - delete view
Cookie assignment - delete view

Program Specifications

  • Create a page which will create one of two different views when it loads depending on whether a cookie is stored for this page. This can be done by creating two div elements, and then deciding which div gets displayed and which one gets hidden by checking to see if the page has a cookie as soon as it is done loading.
  • The first view should be a form which will collect information and store it in two cookies. This page should be created if either or both of the cookies that this page creates are nonexistent or invalid. A sample of this cookie saving view is shown in the Images section of this assignment.
  • If the cookies are present and valid, then the view should be set to display the view which greets the user and allows them to delete the cookies. A sample of this cookie deleting view is shown in the Images section of this assignment. This page should have a delete button which deletes all cookies when clicked, and then reloads the page so the first (cookie saving view) is displayed again.
  • Use the cooklib.js library to make handling the cookies easier.

Grading rubric

  • 5 pts: The page has proper documentation comments and follows current standards.
  • 10 pts: Cookie saving view works properly and saves the field values as cookies.
  • 10 pts: Cookie deleting view works properly and deletes all of the saved cookies.
  • 5 pts: Both views are included on the same page, but only one view shows at a time.
  • 10 pts: The cooklib.js library is included and used properly.