Briefing: Using Cookies

This tutorial will teach you the basics of using Cookies. It will prepare you for the next tutorial, ‘Creating a Simple Login System’.

cookie-2

Specific requirements of tutorial:

  1. Knowledge of HTML and <form>. If I say ‘make a form’ you should know what to do.
  2. Knowledge of $_POST or $_GET, depending on what you decide to use for the form.

(it is assumed that you have all of the requirements specified earlier)

Briefing

  1. Create a form with a single input. When this form is submitted, a cookie should be set. When the user returns to the form, the value that was submitted should appear in the input.
  2. Repeat the first task, but use multiple forms. Multiple cookies should be set.
  3. Modify the second task so that if a specific value is set (ex. name is set to ‘Austin’), a special note will be outputted when the user returns to the form.

If you have any questions regarding the tasks, please leave a comment.

Run Through/Hints

  1. If you aren’t sure how setcookie() works, you should search for some information on it.
  2. Just an expanded version of the first.
  3. There is no need to set extra cookies here. The amount of cookies set should be the same as in the second task. All of your logic should be on the page with the form.

I’ll post the solution to this problem soon. Good luck. :)

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>