Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Delayed cookie update time

Status
Not open for further replies.

Tyger

Programmer
Sep 19, 2001
21
GB
I find that if I create a cookie or update an existing one it takes a little while for the information to be updated. That is: if I have one program which stores a value in an existing cookie, and then another program is run automatically which reads the cookie information, it will read the old value.

This is quite annoying because it means I must send the same data that the cookie should contain, to the second program because I cannot rely on it to read the correct information for itself.

If the second program is not run immediately, ie: there is a delay, then the cookie contains the value it should. It seems that it takes a little while for the new value to be stored.

This happens when I test programs both online, and locally. Is this a common problem, or am I doing something wrong?
 
The reason you're seeing this is because the cookie is a file on the user's system that needs to be saved. While the information is technically there, it takes a little time (more than your program takes to move on) to perminently resave the cookie to that file.

The way I've gotten around similar situations is once I write the information, I use the following line:

sleep 2;

This allows the user's system 2 seconds to resave the information. Change the number to anything you'd like, but usually 2 seconds is plenty of time to do this as I've seen.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top