Question

PART 1: a) Write a short Narrative (one or two paragraphs) on how cookies can be...

PART 1:

a) Write a short Narrative (one or two paragraphs) on how cookies can be used to record information about you as you use a web site.

b)     Discuss the positive and negative aspects of this.

c)     You must answer the question: Is the use of cookies ethical?

PART 2:

a)     Create a simple HTML page with any necessary CSS and Javascript that will set a cookie and then display the cookie on reloading the page.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

PART1

Cookies:

A.

Cookies are the piece of information, generated by webserver and stored in the user computer.That information uses in the future.Cookies are embedded in the HTML web pages.And the information flowing between the user's computer and server.

cookies are implented to allow-user side information in the web page.

                          For example, you opened a website i.e online shopping website.You cart some of the items in the cart.

Then you leaved the website.In this case cookies are stored the information about your carr products.

It shows after you open the online shopping website again.

This is how the cookies are working

B.

Positives and Negatives of Cookies:

Simple to use and Implement:The usage of the cookie is easily implemented as compared to other internet protocals.

Less Memory:It deos not use any resource in the server.And also it deos not use any resource in the user's computer.

So, it will not burden to any server.

Configuration Cookies:

  • Session cookies:

                     The cookies are expired when the session is ended.

  • Persistent cookies:      

                      The cookies existen in the user's computer in specified length of time.

Cookies persist much longer perion of time than session rate.

Domain Specific:

Each has its own cookies.No domain shares cookies with other domain.So cookies are independent.

Disabled by the User:user can disable or enable cookies(user's computer).

Negatives of Cookies:

Not secured:Cookies are not secured.The inforamtion stored as plain text.Any one can open and tamper the cookies.It can be interfered with any external party.

Difficult to decrypt:You can manually encrypt and decrypt the cookies.But it requires extra coding.So it can effect the application.Because time required for the encryption and decryption.

Limitations in size:Several limittaions exit in the cookies text.Each site can hold only twenty cookies.Generally the size is 40kb.

Disabled:The user can disable the use of cookies in the user's computer browser settings.Here the decide to not use cookies in the computer.Even it still working.

Cookies will not work in the browsser if the security levels of the browser is high.

Delete:User can delete the cookies.Here user get more controll over the cookies.

Complex type of Data:complex type of data will not allow in cookies.Only plain text is allow.

C

Is the use of cookies Ethical:

-Many organizations are using cookies.To track every move in your on their site(web site).

-Generally cookie is unique identification number, web server places it on user's computer.

-A serial number for you personally that can be used to retrieve particular record(record means inforamtion) from the database.

-It is usually string of random looking number to enough unique.

-The cookie inforamation in the cookies.txt.Or magic cookie directory in your browser.

-Some of the website will not give a chence to accept ot reject the cookies system

-Some of the website selling information to other website.

-cookies must follow the pop up window to click 'yes' or 'no' that accept or reject.

-Cookies also used to retreive email address in the browser.And any other private data.

PART2:

A HTML WEB PAGE WORKING WITH COOKIES:

index.html

<!doctype html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<link rel="shortcut icon" href="favicon.png" />
<title>How to set cookies with JavaScript Demo</title>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<link rel="stylesheet" type="text/css" href="style.css" />
</head>
<body>
<div id="container">
    <div class="message change-message--on-load hide--second">
      <p>This message is displayed only the first time you visit this page. Refresh your page to hide it!</p>
      <p>This is shown only after the previous message was shown in the last visit. </p>
    </div>

    <div class="message change-message--on-click hide--second">
      <p>You can only hide this message, by clicking the &ldquo;&times;&rdquo; on the right of this box <a href="#" class="close" title="Hide This Message">&times;</a></p>
      <p>This is</p>
    </div>
</div><!--end div_container-->

<footer>
    <div class="reset">To reset, <a href="">remove the cookies</a>.</div>

    <a href="#" class="twitter-share-button" data-via="alexcican" data-related="alexcican">Tweet</a>
    <script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script> </footer>

<script type="text/javascript" src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
<script type="text/javascript" src="cookie.js"></script>
<script type="text/JavaScript">
    $(document).ready(function() {
      // COOKIES
      // if the cookie is true, hide the initial message and show the other one
      if ($.cookie('hide-after-load') == 'yes') {
        $('.change-message--on-load').removeClass('hide--second');
        $('.change-message--on-load').addClass('hide--first');
      }
      // if the cookie is true, hide the initial message and show the other one
      if ($.cookie('hide-after-click') == 'yes') {
        $('.change-message--on-click').removeClass('hide--second');
        $('.change-message--on-click').addClass('hide--first');
      }
      // add cookie to hide the first message after load (on refresh it will be hidden)
      $.cookie('hide-after-load', 'yes', {expires: 7 });
      // when clicked on “X” icon do something
      $('.close').click(function() {
        // check that “X” icon was not cliked before (hidden)
        if (!$('.change-message--on-click').is('hide--first')) {
          $('.change-message--on-click').removeClass('hide--second');
          $('.change-message--on-click').addClass('hide--first');
          // add cookie setting that user has clicked
          $.cookie('hide-after-click', 'yes', {expires: 7 });
        }
        return false;
      })
      //reset the cookies (not shown in tutorial)
      $('.reset a').click(function() {
        // check that if it was cliked before or not
        if (!$(this).hasClass('clicked')) {
          // add class that the link is clicked and shot the footer with delay
          $(this).addClass('clicked');
          // add cookie setting that user has clicked
          $.cookie('hide-after-load', 'no', {expires: 7 });
          $.cookie('hide-after-click', 'no', {expires: 7 });
        }
        location.reload();
      });
    });
</script>
</body>
</html>

Note:http://code.jquery.com/jquery-1.9.1.min.js

ths above javascript must include to work pop up boxess.

You can download and include this file

cookies.js

This file must be include in the web page

javascript code:


(function (factory) {
    if (typeof define === 'function' && define.amd) {
        // AMD. Register as anonymous module.
        define(['jquery'], factory);
    } else {
        // Browser globals.
        factory(jQuery);
    }
}(function ($) {

    var pluses = /\+/g;

    function encode(s) {
        return config.raw ? s : encodeURIComponent(s);
    }

    function decode(s) {
        return config.raw ? s : decodeURIComponent(s);
    }

    function stringifyCookieValue(value) {
        return encode(config.json ? JSON.stringify(value) : String(value));
    }

    function parseCookieValue(s) {
        if (s.indexOf('"') === 0) {
            // This is a quoted cookie as according to RFC2068, unescape...
            s = s.slice(1, -1).replace(/\\"/g, '"').replace(/\\\\/g, '\\');
        }

        try {
            // Replace server-side written pluses with spaces.
            // If we can't decode the cookie, ignore it, it's unusable.
            // If we can't parse the cookie, ignore it, it's unusable.
            s = decodeURIComponent(s.replace(pluses, ' '));
            return config.json ? JSON.parse(s) : s;
        } catch(e) {}
    }

    function read(s, converter) {
        var value = config.raw ? s : parseCookieValue(s);
        return $.isFunction(converter) ? converter(value) : value;
    }

    var config = $.cookie = function (key, value, options) {

        // Write

        if (value !== undefined && !$.isFunction(value)) {
            options = $.extend({}, config.defaults, options);

            if (typeof options.expires === 'number') {
                var days = options.expires, t = options.expires = new Date();
                t.setTime(+t + days * 864e+5);
            }

            return (document.cookie = [
                encode(key), '=', stringifyCookieValue(value),
                options.expires ? '; expires=' + options.expires.toUTCString() : '', // use expires attribute, max-age is not supported by IE
                options.path    ? '; path=' + options.path : '',
                options.domain ? '; domain=' + options.domain : '',
                options.secure ? '; secure' : ''
            ].join(''));
        }

        // Read

        var result = key ? undefined : {};

        // To prevent the for loop in the first place assign an empty array
        // in case there are no cookies at all. Also prevents odd result when
        // calling $.cookie().
        var cookies = document.cookie ? document.cookie.split('; ') : [];

        for (var i = 0, l = cookies.length; i < l; i++) {
            var parts = cookies[i].split('=');
            var name = decode(parts.shift());
            var cookie = parts.join('=');

            if (key && key === name) {
                // If second argument (value) is a function it's a converter...
                result = read(cookie, value);
                break;
            }

            // Prevent storing a cookie that we couldn't decode.
            if (!key && (cookie = read(cookie)) !== undefined) {
                result[name] = cookie;
            }
        }

        return result;
    };

    config.defaults = {};

    $.removeCookie = function (key, options) {
        if ($.cookie(key) === undefined) {
            return false;
        }

        // Must not alter options, thus extending a fresh object...
        $.cookie(key, '', $.extend({}, options, { expires: -1 }));
        return !$.cookie(key);
    };

}));

style.css

The style.css file is used to make our webpage most beautifule.And attarctively

css

body {
font-family: "Helvetica Neue", 'Helvetica', sans-serif;
color: #666;
margin: 1em;
line-height: 2;
}
/*#footer {
position: fixed;
margin-top: 50px;
bottom: 0px;
background: rgba(0,0,0,0.7);
color: #fff;
height: 30px;
padding-top: 10px;
text-align: center;
}*/
a:link,
a:visited /* styles the links */ {
color: #f00;
text-decoration: none;
padding-bottom: 0.1875em; /* 3px / 16px */
}
a:hover /* changes the colour of text when hovered */ {
color: #fe580f;
cursor: pointer;
}
.hide--first > *:first-child {
display: none;
}
.hide--second > *:last-child {
display: none;
}
.message {
font-size: 1.5em;
text-align: center;
width: 42%;
padding: 0 2%;
float: left;
background: #eee;
}
.message:last-of-type {
float: right;
}
.close {
color: #f00;
position: absolute;
text-transform: lowercase;
right: 20px;
font-size: 1.5em;
top: 10px;
line-height: 1;
border: none !important;
}
p.info {
font-size: 19px;
margin-bottom: 50px;
text-align: center;
}
p.info span { color: #666 }
footer:before{
content: "";
display: table;
clear: both;
}
footer {
padding-top: 40%;
color: #888;
text-align: center;
}
.twitter-share-button {
vertical-align: -15%;
margin-right: -25px !important;
}

Output:

Now click on the close button above i that is X

after clicking

Now click on the remove the cookies.

after clicking this

Now the closing button that X is appearing again.

So cookies are working perfectly.

Add a comment
Know the answer?
Add Answer to:
PART 1: a) Write a short Narrative (one or two paragraphs) on how cookies can be...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • i need help with this homework webpage and code too: The webpage must include: Global Structure...

    i need help with this homework webpage and code too: The webpage must include: Global Structure Tags Text Tags Images   Your first page must be named index.html Include a table within your site, challenge yourself to add a header in the table, and choose interesting border and/or cell formatting. Include a hyperlink within your site. Include an image in your site. Include a form in your site to demonstrate understanding of a variety of form components (the form does not...

  • For milestone #1, we will start the CARIT site with three static HTML pages and a...

    For milestone #1, we will start the CARIT site with three static HTML pages and a CSS file. Create a dedicated folder for this project. This folder should contain all related files in this project. The future milestones are cumulative and built directly on top of your prior work. Function/content requirements: A home page named “index.html”, which include these contents at least: Description of the center. You may reference the example sites. Latest news: use list tags; make up some...

  • Create an HTML5 page that contains a form to collect the following data. The text in...

    Create an HTML5 page that contains a form to collect the following data. The text in bold indicates the id value that should be assigned to each html control: Product (drop down list) product – iPad, iPhone 6S, Galaxy 5S, Moto X, and so on Quantity (number) quantity Unit price (number) unit_price Discount (%)(number) discount_rate Date (date)   order_date First Name (text box)   first_name Last Name (text box)   last_name Payment type (drop down list)   payment_type – Visa, Master, Discover, Amex, and...

  • Design an original, professional web site following the specifications listed below. This web sit...

    Design an original, professional web site following the specifications listed below. This web site will be for a business you plan to set up for yourself or for someone else. The following is a detailed list of the requirements for your web site. READ them carefully. Instructions - Web Site Requirements for the web site: General: You will thoroughly test all your pages in more than one browser. All links MUST work. All graphics must show on the page. All...

  • Creating the Home and Template Pages Overview In this assignment, you will start building your Web...

    Creating the Home and Template Pages Overview In this assignment, you will start building your Web site for your fictional organization by creating a homepage using HTML5 and some of the key elements that define a Web page. You are required to use either a simple text editor to write your code, or an enhanced text editor such as Brackets. Note: Microsoft Word is not a good tool for developing code because it is a document processor and not a...

  • Part - Web Server Setup and Demonstration (AJ Objective The objective of this assignment is to...

    Part - Web Server Setup and Demonstration (AJ Objective The objective of this assignment is to some HTTP as application layer protocol and TCP as reliable transport layer protocol HTTP is carried by TCP. Also, in the assignment you will investigate the working of client-server mechanism from both application and networking perspective There are several different ways to setup an HTTP server, including through Apache Tomcat, Apache Glassfish that integrales in an IDE such as Eclipse/NetBeans or even a browser...

  • Question 1 To remove the underlining from an <a> element, you can use CSS to set...

    Question 1 To remove the underlining from an <a> element, you can use CSS to set its A. text-decoration property to none B. text-decoration property to off C. underline property to none D underline property to off Question 2 You can use the CSS list-style-type property to change A. the bullet style in an unordered list B the number style in an ordered list C the terms style in a description list Dthe bullet or number style in an unordered...

  • Question 1 To remove the underlining from an <a> element, you can use CSS to set...

    Question 1 To remove the underlining from an <a> element, you can use CSS to set its A. text-decoration property to none B. text-decoration property to off C. underline property to none D underline property to off Question 2 You can use the CSS list-style-type property to change A. the bullet style in an unordered list B the number style in an ordered list C the terms style in a description list Dthe bullet or number style in an unordered...

  • the is my HTML and CSS code. I didn't attach the image or the CSS file...

    the is my HTML and CSS code. I didn't attach the image or the CSS file because of the space limit. two things I wanted to incorporate on this page are to make "MY TOP 3 MUSIC GENRES" blink using javascript and to make the video links autoplay using javascript both should be using javascript requirement: our professor told us not to use <div> or alert. thank you for your help <!DOCTYPE html> <!-- I used w3school for the formatting...

  • Code for the movies page: <html lang="en"> <head> <meta charset="UTF-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" />...

    Code for the movies page: <html lang="en"> <head> <meta charset="UTF-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <link rel="stylesheet" type="text/css" href="style.css" /> <title>Daniel's Movie Page</title> </head> <body> <a href="hobbies.html">Hobbies</a> <h1>Movies and Actors</h1> <ol> <li class="ol-list1">Gravity</li> <li>Avenger</li> <li>Marshal</li> <li>Interstellar</li> <li>Dark Knight</li> <li>Superman</li> </ol> <ul> <li class="ul-list1">Robet Downey jr.</li> <li>Sharuk Khan</li> <li>Ranbir Kapoor</li> <li>Sidhhart Malhotra</li> <li>Angela Joli</li> <li>Leonardo DiCaprio/li> </ul> <h2>Favorite Movie</h2> <p> <b>Gravity:</b> The movie portrayed what happens to an astronaut if he/she is pushed away from spaceship.It was terrifying how much...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT