#1
  1. No Profile Picture
    Aaron Moore
    Guest
    Devshed Newbie (0 - 499 posts)
    Im in the process of finishing up a script that stores cookies of items that users have selected from a page. On one page of the site, The cookies are retrieved, and are set into a textbox. Anyways, For some reason, I can only store 20 cookies. I know that you can store like 300 something into a file, but for some reason it stops at 20. When I select more than 20, it adds them to the cookie file, and over-writes the last 20...
    Can ANYONE help out??? I know the code isnt restricting it from writeing them (atleast i think not). Could it be cause Im viewing the page on my DASD? I havent published it to the net yet to test it. I dont see why that would make a dif. Thanks.

    ------------------
    Aaron M.
    The Power Company
    Internet Design/Hosting/Marketing
    http://www.thepowercompany.org
  2. #2
  3. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2001
    Posts
    1
    Rep Power
    0
    Aaron,
    There is a limit to the number of cookies that a browser will accept from a domain. That limit is 20. Each cookie can be up to 4k in size, so you will want to maximize the amount of data that you place in each cookie such as:

    document.cookie="cookie_1=username:speedy/first_name:Ralph/last_name:Jones/address:1234 Evergreen Circle/city:Plano/state:TX/zip:75075";//This could go on and on for up to 4k of info

    perhaps on another page
    document.cookie="cookie_2=more_name_value_pairs:various_values";//again use up to 4k

    Here is a function I use to get all of my cookies and place them into a two diminsional array so that the values can be accessed as follows:

    my_cookie = getcookies();

    alert("Your name is " + mycookie["cookie_1"]["first_name"]);

    function getcookies(){

    var arr = new Array();
    var the_cookies = document.cookie;
    var raw_cookies=the_cookies.split("; ");
    for (x=0;x<raw_cookies.length;x++){
    var tmp_arr= new Array();
    var tmp_raw_cookies = raw_cookies[x].split("=");
    var tmp_cookie_names = unescape(tmp_raw_cookies[1]).split("/");
    for (y=0;y<tmp_cookie_names.length;y++){
    var tmp_cookie_vals = tmp_cookie_names[y].split(":");

    tmp_arr[tmp_cookie_vals[0]] = tmp_cookie_vals[1];

    }
    arr[tmp_raw_cookies[0]] = tmp_arr;
    }
    return arr;
    }

Similar Threads

  1. Javascript and cookies
    By soon in forum JavaScript Development
    Replies: 2
    Last Post: February 3rd, 2004, 09:21 AM
  2. Create/Access Cookies in ASP and Client-Side Javascript
    By greggjc in forum JavaScript Development
    Replies: 0
    Last Post: November 19th, 2003, 04:24 PM
  3. cookies and javascript
    By soon in forum JavaScript Development
    Replies: 2
    Last Post: November 7th, 2003, 06:56 AM
  4. Manipulating cookies with javascript
    By andyg1 in forum JavaScript Development
    Replies: 0
    Last Post: August 13th, 2003, 02:44 PM
  5. Javascript, cookies & CSS
    By firelegend in forum JavaScript Development
    Replies: 4
    Last Post: May 4th, 2003, 07:02 PM

IMN logo majestic logo threadwatch logo seochat tools logo