Click to See Complete Forum and Search --> : Max. Cookie Size


discotraveler
07-21-2003, 10:04 PM
Hello,

I modifyed the Bookmarks,http://javascript.internet.com/miscellaneous/bookmarks.html , script from Javascript source for my website.

Instead of storing a a webaddress, I modifyed it to store a rides name and a desciption. (If it doesn't make sense visit my website, http://www.discotraveler.com, and you will understand :) )

I modifyed it so that a user could create their own personalized "favoirite attraction list." My problem comes in when you add, basically more then 8 or 9 'attractions' to the list, IE ONLY (does not affect Mozilla or Netscape), they will not show up any more.

So my question is, does IE put a cap on the size of a cookie.

To use my modified code, go to these three pages:
http://www.discotraveler.com/parks/florida/disney_world/magic_kingdom/adventureland.htm

http://www.discotraveler.com/parks/florida/disney_world/magic_kingdom/frontierland.htm

http://www.discotraveler.com/parks/florida/disney_world/magic_kingdom/fantasyland.htm
and click the "add attraction to day planner' for each of the attractions on each page.

Or maybe there is something wrong with the source code:

// <script language="JavaScript">
<!-- Original: Pete Thompson (thompp@globalnet.co.uk) -->
<!-- Web Site: http://www.users.globalnet.co.uk/~thompp -->

<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! http://javascript.internet.com -->
// <!-- Begin

// ** bookmark functions

var sepchar = "@"; // unique separator character
var BMtotal = 99; // max number of bookmarks permitted
var ShowCount = 0;
var expDays = 30; // cookie variables - expiry # days

var exp = new Date();
exp.setTime(exp.getTime() + (expDays*24*60*60*1000));

function ListBookmarks()
{
var NumBookmarks = GetCookie('MK_NumBookmarks');
var i;
var Bookmark;

// alert("ListBookMarks started");

if (NumBookmarks == null)
{
NumBookmarks = 0;
}
ShowCount = 0; SwapColour = 0;

for (i=1; i <= NumBookmarks ; i++)
{
Bookmark = GetCookie('MK_Bookmark'+i);
if (Bookmark != null)
{
PrintBookmark(Bookmark, i);
}
}
}

function DeleteBookmark(Count)
{
DeleteCookie('MK_Bookmark'+Count);
window.location = window.location;
}

function PrintBookmark (Bookmark, Count)
{

var color = "";
var pairs = Bookmark.split(sepchar);
pairs[0]= unescape(pairs[0]);
pairs[1]= unescape(pairs[1]);
// alert(Bookmark+" "+sepchar);
var BMtitle = pairs[0];
var BMaddress = pairs[1];
//alert(BMaddress);

// SwapColour = 1 - SwapColour;
// if (SwapColour==1) {color = "bgcolor='#c0c0c0'"} ;

ShowCount++;
document.write("<td width=95% align=left><font size='2' face='Verdana' color='#000000'><p style='word-spacing: 0; margin-top: 0; margin-bottom: 0'><medium><medium>"+BMtitle+"</medium></medium></font>");
document.write("<td width=5% align=center><small><small>"+"<a href='javascript:DeleteBookmark(" + Count + ")'>Delete</a><p>");
}

function AddBookmark(BMtitle, BMaddress)
{

var NumBookmarks = GetCookie('MK_NumBookmarks');
var i;
var ToDoItem;
var Bookmark;
var OldestBookmark = 0;
var CountBookmarks = 0;

if (NumBookmarks == null)
{ NumBookmarks = 0; }

// check if already exists, and count bookmarks
for (i=1; i <= NumBookmarks ; i++)
{
Bookmark = GetCookie('MK_Bookmark'+i);
if (Bookmark != null)
{ CountBookmarks++;
if (OldestBookmark == 0)
{ OldestBookmark = i; }
}

if (Bookmark == BMtitle+sepchar+BMaddress)
{ alert(This attraction has already been added to your planner.);
return; }
}
// now add it
NumBookmarks++;
//alert('MK_Bookmark'+NumBookmarks);
SetCookie('MK_Bookmark'+NumBookmarks, BMtitle+sepchar+BMaddress, exp);
SetCookie('MK_NumBookmarks',NumBookmarks, exp);
//window.location = window.location;
}

// cookie functions

function getCookieVal (offset) {

var endstr = document.cookie.indexOf (";", offset);

if (endstr == -1)
endstr = document.cookie.length;
return unescape(document.cookie.substring(offset, endstr));

}

function GetCookie (name) {

var arg = name + "=";
var alen = arg.length;
var clen = document.cookie.length;
var i = 0;

while (i < clen) {
var j = i + alen;
if (document.cookie.substring(i, j) == arg)
return getCookieVal (j);
i = document.cookie.indexOf(" ", i) + 1;
if (i == 0) break;
}
return null;
}

function SetCookie (name, value) {

var argv = SetCookie.arguments;
var argc = SetCookie.arguments.length;
var expires = (argc > 2) ? argv[2] : null;
var secure = (argc > 5) ? argv[5] : false;

document.cookie = name + "=" + escape (value) +
((expires == null) ? "" : ("; expires=" + expires.toGMTString())) +
((secure == true) ? "; secure" : "");

}

function DeleteCookie (name) {

var exp = new Date();

exp.setTime (exp.getTime() - 1);
var cval = GetCookie (name);
document.cookie = name + "=" + cval + "; expires=" + exp.toGMTString();
}

// End -->

// </script>


Thank you to whoever can help, and like I said before, this only happens in IE, there is no problem in Mozilla or Netscape.

-Andrew
webmaster@discotraveler.com:)