Discussion :  SOU CS Classes The fastest message board... ever.
Forum for discussion, questions, and replies relating to Web Development I 
Goto Thread: PreviousNext
Goto: Forum ListMessage ListNew TopicSearchLog In
Week 10 - Wednesday Discussion
Posted by: harveyd (IP Logged)
Date: November 26, 2007 03:40PM

1. What is a cookie?
2. How do you create a cookie in JavaScript?
3. How do you create a cookie with an expiration date thirty days in the future?
4. Suppose you create two cookies: "name=dan" and "email=harveyd@sou.edu." What is the JavaScript code to retrieve them and display them in an alert message?
5. Why do most cookies require expiration dates?
6. How do cookies enable e-commerce applications?
7. How can JavaScript read and display information from a previously written cookie?
8. Explain how the JavaScript substring method works. Give an example.
9. Explain how the JavaScript split method works.
10. Give us an advantage and a disadvantage of using cookies.
11. Find an article discussing security and cookies.
12. What ideas do you have for the ACORNS language learning site?
13. Find an article discussing creating your own objects in JavaScript.
14. What is a good discussion topic for future classes?
15. What would be a good lab project?
16. Create a test question that you think would be good to add to either the on-line lecture, for a synthesis question, or for a quiz. Answer your question.
17. What do you wish you knew at the start of the lab project?
18. What suggestions do you have for the on-line lectures, lab projects, power point slides, etc.?
19. What mistakes did you find in the on-line material?

Re: Week 10 - Wednesday Discussion
Posted by: (IP Logged)
Date: November 27, 2007 04:37PM

1. What is a cookie?
A cookie is a piece of information sent to a browser by a Web Server. The browser then returns that information to the Web server. .

Note from Dan: A cookie is a small text file written to the client disk using a client side script.

. How do you create a cookie with an expiration date thirty days in the future?

function createCookie(name,value,days) {
if (days) {
var date = new Date();
date.setTime(date.getTime()+(days*24*60*60*1000));
var expires = "; expires="+date.toGMTString();
}
else var expires = "";
document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
var nameEQ = name + "=";
var ca = document.cookie.split(';');
for(var i=0;i < ca.length;i++) {
var c = ca[i];
while (c.charAt(0)==' ') c = c.substring(1,c.length);
if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
}
return null;
}

function eraseCookie(name) {
createCookie(name,"",-1);
}



Edited 1 time(s). Last edit at 11/27/2007 06:00PM by harveyd.

Re: Week 10 - Wednesday Discussion
Posted by: (IP Logged)
Date: November 27, 2007 07:46PM

1. What is a cookie?
A cookie is a small text file written to the client's computer, to save info when the browser closes, track user purchases, that kind thing. data relevant to the website.
2. How do you create a cookie in JavaScript?
document.cookie="userName=John doe";

3. How do you create a cookie with an expiration date thirty days in the future?
var expDate = new Date();
expDate.setMonth(expDate.getMonth() +1);
document.cookie="greeing=Hello World;expires=" + expDate.toGMTString();

4. Suppose you create two cookies: "name=dan" and "email=harveyd@sou.edu." What is the JavaScript code to retrieve them and display them in an alert message?
alert(document.cookie)

Note from Dan: This would work, but it doesn't split the cookies apart.


5. Why do most cookies require expiration dates?
to enforce security measures. To keep data only for a short period of time.

10. Give us an advantage and a disadvantage of using cookies.
an advantage is that it simplifies future visits to the same site (rememember user name/password,) Disadvantage is it allows an 'in' for hackers on some pc's


11. Find an article discussing security and cookies.
[www.webopedia.com]

13. Find an article discussing creating your own objects in JavaScript.
[www.javascriptkit.com]

17. What do you wish you knew at the start of the lab project? I wish I had gone to class to listen to the lecture, that way the lab probably wouldn't've taken me quite so long.

18. What suggestions do you have for the on-line lectures, lab projects, power point slides, etc.? Nothing actually, it's a very good system. I wish there were some kind of reminder system, especially since i don't check my school email very often...


19. What mistakes did you find in the on-line material?
the only thing i found was on the first slide of week 10, it had a C at the very begining instead of an A



Edited 1 time(s). Last edit at 11/27/2007 10:09PM by harveyd.

Re: Week 10 - Wednesday Discussion
Posted by: (IP Logged)
Date: November 28, 2007 11:47PM

7. How can JavaScript read and display information from a previously written cookie?

Without a split:
<head>
<script type="text/javascript">
alert(document.cookie);
</script>
</head>
<body>

With a split:
<head>
<script type="text/javascript">
var cookies=document.cookies
var amazonCookies=cookies.split(";");
alert(amazonCookies[0].split("=")[1];
alert(amazonCookies[1].split("=")[1];
alert(amazonCookies[2].split("=")[1];
alert(amazonCookies[3].split("=")[1];
alert(amazonCookies[4].split("=")[1];
</script>
</head>
<body>

6. How do cookies enable e-commerce applications?

a. store information about a shopper's shopping cart
b. create a personalized greeting when a shopper next visits the site
c. keep track of log-in and password information without transmitting it over the web

Re: Week 10 - Wednesday Discussion
Posted by: (IP Logged)
Date: November 29, 2007 12:38PM

1. What is a cookie?
A cookie is a small text file written to the client's computer

2. How do you create a cookie in JavaScript?
document.cookie =

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()

4. Suppose you create two cookies: "name=dan" and "email=harveyd@sou.edu." What is the JavaScript code to retrieve them and display them in an alert message?

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?
shopping carts use cookies to remember what items you selected.

7. How can JavaScript read and display information from a previously written cookie?
JavaScript is limited to reading only the name and value of a cookie. To read the contents of a cookie string, we split it apart into its name and its value by using the split() method.

8. Explain how the JavaScript substring method works. Give an example.

The substring() method extracts the characters in a string between two specified indices.


9. Explain how the JavaScript split method works.
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.

[wssg.berkeley.edu]

13. Find an article discussing creating your own objects in JavaScript.

[www.howtocreate.co.uk]

Re: Week 10 - Wednesday Discussion
Posted by: (IP Logged)
Date: December 02, 2007 10:53PM

11. Find an article discussing security and cookies.

[support.microsoft.com]
[www.cookiecentral.com]
[www.news.com]

13. Find an article discussing creating your own objects in JavaScript.

[www.javascriptkit.com]
[www.w3schools.com]
[articles.techrepublic.com.com]



Sorry, only registered users may post in this forum.
This forum powered by Phorum.