homeGeek CultureWebstoreeCards!Forums!Joy of Tech!AY2K!webcam

The Geek Culture Forums


Post New Topic  New Poll  Post A Reply
my profile | directory login | | search | faq | forum home
  next oldest topic   next newest topic
» The Geek Culture Forums   » Other Geeky Stuff   » Ask a Geek!   » Cookie Question

 - UBBFriend: Email this page to someone!    
Author Topic: Cookie Question
Stereo

Solid Nitrozanium SuperFan!
Member # 748

Member Rated:
5
Icon 1 posted November 22, 2010 12:47      Profile for Stereo     Send New Private Message       Edit/Delete Post   Reply With Quote 
Where to start... I collaborate on a project at work, in which an online course, meant to have its data captured by a server-side script (or presented to the user then not forgotten) is augmented with javascript so the answers are stored in a cookie, then passed on over a secured connection to the network. (I know it may sound strange, but there is a technical reason it is done this way, believe me.) The guy who created the javascript isn't a programmer. He doesn't really know JavaScript, and merely copy-pasted code from examples available online. It did work for a test-drive having only one test.

Some extra technical information: courses must be done on laptops with their configuration closely controlled, using Internet Explorer 8 (I think), with Windows XP.

Now, where it doesn't work: this new course has 5 tests. The two first tests have their answers stored in files with names like [email protected]~~local~~(path to the html file setting the cookie)_[X] with [X] being usually [1], but sometimes [2] and when it is [2], its name and content has been changed by another html file from another path.

From what I could see on the net, a file created under with one path cannot be modified by a second file from another path. Still it happens.

For a better idea, here is how things happen in order:

First test: creates first cookie file.
Second test: creates second cookie file.
Third test: truncates first cookie file, rename first cookie file (now ending with a [2]), and creates third cookie file.
Fourth test: deletes first cookie file, trucates and rename second cookie file, and creates fourth cookie file.
Fifth test: deletes second cookie file, truncates and rename third cookie file, creates fifth cookie file.

All those have different paths; yet saving new tests results cause previous cookie files to be modified/deleted.

For what I could see, the limit of the HTML header should be 4ko; each cookie file is way below that. And my understanding is that cookies from another path will not be passed in the HTML header.

So, I am at a loss. Is there some Internet Explorer extra limitation on cookies from the same domain? Is it the fact that it is created locally rather than from a server? Anyone has an idea of what is going on, and how to make sure older data doesn't get deleted?

(We have checked expiration dates. We have tried setting a path, but the format might have been wrong since no cookie file would be created at all.)

Here is the code. I know it is not optimal - again, copy-pasted by someone who knows close to no Javascript and even less about programming. We have changed the expiry date handling so the expiredays is no longer used.

code:
 
function setCookie(c_name,value,expiredays)
{
var excate=new Date;
exdate.setYear(exdate.getYear()+10);
document.cookie=c_name+"="+unescape(value)+"; expires="exdate.toGMTString();
}

(I have tried adding +"path=http://localhost/path/to/file" between the expires value and the end of the statement, but it caused the cookie file not to be created at all.)

Then this function is called each time a name-value pair needs to be kept (questions=answer plus some extra information about the test and course identification).

Would anyone have an idea of what is going on? Even a hint? Please?

Edit:

Ok. I may have found the reason. Microsoft page on IE cookie limitations:
quote:
By default, Internet Explorer can store a maximum of 20 cookies for each domain. If a server in the domain sends more than 20 cookies to a client computer, the browser on the client computer automatically discards some old cookies.
Since the current usage surpass the 20 cookies limit, perhaps even the 50 one, we may have to concatenate cookies. Which is no good news on my part...

--------------------
Eppur, si muove!

Galileo Galilei

Posts: 2289 | From: Gatineau, Quebec, Canada | Registered: Apr 2001  |  IP: Logged
TheMoMan
BlabberMouth, a Blabber Odyssey
Member # 1659

Member Rated:
4
Icon 1 posted November 23, 2010 11:35      Profile for TheMoMan         Edit/Delete Post   Reply With Quote 
____ Stereo, I prefer Oatmeal Chocolate chip, "TOLLHOUSE."

--------------------
Those who would give up essential liberty to purchase a little temporary safety deserve neither liberty nor safety.


Benjamin Franklin,

Posts: 5848 | From: Just South of the Huron National Forest, in the water shed of the Rifle River | Registered: Sep 2002  |  IP: Logged


All times are Eastern Time  
Post New Topic  New Poll  Post A Reply Close Topic    Move Topic    Delete Topic next oldest topic   next newest topic
 - Printer-friendly view of this topic
Hop To:

Contact Us | Geek Culture Home Page

© 2015 Geek Culture

Powered by Infopop Corporation
UBB.classicTM 6.4.0



homeGeek CultureWebstoreeCards!Forums!Joy of Tech!AY2K!webcam