Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Page 1 of 2 12 LastLast
Results 1 to 15 of 18

Thread: Using cookies

  1. #1
    Regular Coder
    Join Date
    Oct 2003
    Location
    SC
    Posts
    936
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Using coooookies

    How can i use use my cookies to retrive data?

    Edit: a use too much --> delete

  • #2
    Senior Coder
    Join Date
    Aug 2002
    Location
    Kansas City, Kansas
    Posts
    1,518
    Thanks
    0
    Thanked 2 Times in 2 Posts
    Check out this tutorial on cookies.

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

  • #3
    Regular Coder
    Join Date
    Oct 2003
    Location
    SC
    Posts
    936
    Thanks
    0
    Thanked 0 Times in 0 Posts
    <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

  • #4
    Banned
    Join Date
    Sep 2003
    Posts
    3,620
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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

  • #5
    Regular Coder
    Join Date
    Oct 2003
    Location
    SC
    Posts
    936
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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; 02-08-2004 at 08:14 PM.

  • #6
    Regular Coder
    Join Date
    Oct 2003
    Location
    SC
    Posts
    936
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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

  • #7
    Regular Coder
    Join Date
    Oct 2003
    Location
    SC
    Posts
    936
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I added this:

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

    now it works.... thanks for all the given help

  • #8
    Regular Coder
    Join Date
    Oct 2003
    Location
    SC
    Posts
    936
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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?

  • #9
    Smokes a Lot
    Join Date
    Jul 2003
    Location
    CA, USA
    Posts
    1,594
    Thanks
    5
    Thanked 20 Times in 20 Posts
    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

  • #10
    Regular Coder
    Join Date
    Oct 2003
    Location
    SC
    Posts
    936
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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

  • #11
    Regular Coder
    Join Date
    Oct 2003
    Location
    SC
    Posts
    936
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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

  • #12
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    10,965
    Thanks
    0
    Thanked 236 Times in 233 Posts
    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:
    Cookies and OOP

  • #13
    Regular Coder
    Join Date
    Oct 2003
    Location
    SC
    Posts
    936
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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

  • #14
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    10,965
    Thanks
    0
    Thanked 236 Times in 233 Posts
    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?

  • #15
    Regular Coder
    Join Date
    Oct 2003
    Location
    SC
    Posts
    936
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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


  •  
    Page 1 of 2 12 LastLast

    Posting Permissions

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