Web Analytics Made Easy -
StatCounter Using cookies - CodingForum

Announcement

Collapse
No announcement yet.

Using cookies

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Using cookies

    How can i use use my cookies to retrive data?

    Edit: a use too much --> delete
    http://www.bluephoenix.uni.cc/

  • #2
    Check out this tutorial on cookies.

    http://hotwired.lycos.com/webmonkey/...tw=programming

    Comment


    • #3
      <script>
      var the_name = prompt("What's your name?","");
      document.cookie = the_name;
      alert("Thanks, now go to the next page.");
      </script>

      TO SET THE COOKY

      <script>
      var the_cookie = document.cookie;
      alert("Your name is: " + the_cookie);
      </script>

      TO READ IT

      but how did it know which cooky to read
      http://www.bluephoenix.uni.cc/

      Comment


      • #4
        Originally posted by JAVAEOC
        but how did it know which cooky to read
        Evidently, you looked at the first script example without reading the tutorial.

        Perhaps you should try first reading the tutorial, then asking
        for clarification on a particular point you do not understand.

        .....Willy

        Comment


        • #5
          I did read the tuturial thats how i knew i can delelte all the extra stuff

          but on page 10 i get terrible lost
          Last edited by JAVAEOC; Feb 8, 2004, 03:14 PM.
          http://www.bluephoenix.uni.cc/

          Comment


          • #6
            Now I tried this
            Code:
            var broken_cookie = document.cookie.split(":");
            var RightClick = broken_cookie[0];
            var StyleNum = broken_cookie[1];
            if(document.cookie==''){RightClick=0;StyleNum=0}
            if(document.cookie==''){RightClick=0;StyleNum=0} this was for when the user logs on the page for the first time, so it still displays a style sheet.

            This worked great on my PC
            just as i wanted it to

            but now i uploaded it to my server (brinkster.com) and it chages the cookie in some way it adds a weird Brinkster=0 or Brinkster=3 or sometimes just this #LSDAKJFSLKAF#DLKSJF0923490USD78923#@$LKSFJD

            just random numbers and letters

            this makes it impoosbile for me to retrive the information i stored.....

            please help.

            Here the link to the broken page -->

            http://www34.brinkster.com/dgothe/db/DominiksBeta.html

            it will alert the cookie value at the beginning so that you see whats going on

            thanks alot
            http://www.bluephoenix.uni.cc/

            Comment


            • #7
              I added this:

              var broken = document.cookie.split(";");
              var broken_cookie = broken[1].split(":");

              now it works.... thanks for all the given help
              http://www.bluephoenix.uni.cc/

              Comment


              • #8
                On this page i am using cookies
                http://www34.brinkster.com/dgothe/db/DominiksBeta.html

                they work great when i hit the refresh button but they do not work if i close the browser and reopen it

                why?
                http://www.bluephoenix.uni.cc/

                Comment


                • #9
                  You have to set the expiration date of the cookie.

                  http://hotwired.lycos.com/webmonkey/...tw=programming

                  Basscyst
                  Helping to build a bigger box. - Adam Matthews

                  Comment


                  • #10
                    GOSH

                    I am so lost please help me write a simple cookie script

                    i tried the tutorial but im too dumnb for it

                    please....

                    all i need is to store and retrive two variables.... please

                    thanks for any help
                    http://www.bluephoenix.uni.cc/

                    Comment


                    • #11
                      The script on this page doesnt work, why?

                      http://www34.brinkster.com/dgothe/cookie.htm

                      it works fine on my hard drive but it doesnt work when i upload it....

                      thnaks
                      http://www.bluephoenix.uni.cc/

                      Comment


                      • #12
                        One or more cookies can be saved in the browser. So cookie names do not always located at the start. In your page, the cookie string is:

                        BrinksterServer=1; cookey=muahah

                        Your script assumes the cookie is always at the start that's why your script fails when looking for cookey. There are many cookie scripts in the internet and in this forum, why not use them?

                        Here's one from Post a Javascript forum:
                        http://www.codingforum.net/showthrea...threadid=11585
                        Glenn
                        vBulletin Mods That Rock!

                        Comment


                        • #13
                          Glenn... thanks for that, but i already saw it...

                          Well the stuff they where doing there was WAY over my small head... So i wasnt able to throw together a working html file

                          that is why i started this thread...

                          so I would really appreciate it if you could throw together a working script and attach it....

                          thanks alot
                          http://www.bluephoenix.uni.cc/

                          Comment


                          • #14
                            The code in the link I gave you is already a working script and easy to use. It has attachment of the full documentation on its usage. Did you even try to create a simple page using that script?
                            Glenn
                            vBulletin Mods That Rock!

                            Comment


                            • #15
                              glenngv... heres what i am having truble with:

                              OK the script works fine, the thing now is that when i alert(document.cookie) then it is supposed to alert all the cookies ... right?

                              but it doesnt it doesnt alert the cookie that i jsut set... why?

                              P.S. the reason why I didnt get the script to work is because i misspelled the cookie name lol and my javascirpt console is broke so....

                              thanks glenngv
                              http://www.bluephoenix.uni.cc/

                              Comment

                              Working...
                              X