Hi guys
I've come across a problem with cookies. It seems that if one attempts to
save several cookies in quick succession and then read them back again, you
may attempt to read a cookie that has not yet been saved from the first
operation. I assume that this is because JavaScript via the browser hands
the job over to the OS and then merrily proceeds upon its way.
As it happens, I solved the problem by rewriting my code to use one large
cookie that I could split into an array and hold as a global. I could then
manipulate it at will, and only when I had finished with it did I then
reassemble it into a string and then save it as a cookie in one shot.
Just as a matter of interest, I tried saving that same cookie and reading it
back immediately. The result came back as "undefined". But saving it and
then waiting a while (about 15 secs) and then reading it back, I got the
result I'd expected. I cleared the cookies before each test to make sure I
had clean results.
So my questions are this. Am I correct about the lag between JS and the OS?
Is there a methodical way of ensuring that a cookie has been written before
trying to read it back?
I hope I've explained that well enough. Many thanks for any advice.
Ian