1. What is a cookie?
A cookie is a small text file written to the client's computer
It may contain up to five parts: cookie name/value, expiration date, pathname of web page creating the cookie, domain name of the sever creating the cookie, and security parameter that may restrict access to the cookie.
3. How do you create a cookie with an expiration date thirty days in the future?
var expDate = new Date()
var currentMonth = expDate.getMonth()
expDate.setMonth(currentMonth + 1)
var theName = document.someForm.name.Box.value
document.cookie = “username=” + theName + “;expires=” + expDate.toGMTString()
alert(document.cookie = “name=” + name + “email=” + email;)
5. Why do most cookies require expiration dates?
If we do not specify an expiration date when creating a cookie, the browser never writes the cookie to the cookie file.
6. How do cookies enable e-commerce applications?
The substring() method extracts the characters in a string between two specified indices.
The Split() method is part of all sting objects. You use it by selecting a character as a dividing point. It then looks for that character in the string and splits the string anyplace the character occurs. It stores the string as multiple pieces in an array.
10. Give us an advantage and a disadvantage of using cookies.
Advantages: they store helpful information for the consumer, such as usernames, passwords, shopping cart items, etc.
Disadvantages: limited to 2,000-4,000 characters. # of cookies created by web pages from certain domains may not exceed 4,000 characters in all. Some browsers do not allow cookies.
11. Find an article discussing security and cookies.