SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Enthusiast
    Join Date
    Dec 2010
    Posts
    47
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    A little info on this cookie example, pls.

    Hi,

    Before I started this exercise on cookies below, the author had be set my browser (firefox in my case) to ask every time, so it would ask if I wanted to allow the cookie.
    First I set myCookie to just the cookieName & value, and it worked as expected --the browser displayed the privacy alert asking me if I wanted to allow the cookie, as expected. Then I added the date, and again I got the privacy alert, just as I was supposed to. Next the path -- same results.

    But, when I added the domain, I did not get the privacy alert. Can you pls. tell me why not?

    Thanks,
    Jeff

    <html>
    <head>
    <title>Hello Cookie</title>
    <script type = "text/javascript">

    var cookName="testcookie";
    var cookVal="testvalue";

    var date = new Date();
    date.setTime(date.getTime()+604800000)
    var expireDate = date.toGMTString();

    var path=";path=/";
    var domain = ";domain=braingia.org";

    var myCookie=cookName + "=" + cookVal + ";expires=" + expireDate + path + domain;
    document.cookie = myCookie;
    </script>
    </head>
    <body>
    <p>Hello</p>
    </body>
    </html>

  2. #2
    SitePoint Enthusiast
    Join Date
    Dec 2010
    Posts
    47
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Oh, I think I already know..it's because the domain must specify the server that's sending the content, right? It that's it, then how do I test this? I'm just running this code on my computer -- what would I use for the domain name?
    Thanks,
    Jeff


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •