Bug in cookie handling code
Hi,
I've found a bug in the sample code on [new user link]. The Get_cookie() funtion uses global variable "i" as a loop index. Thus, this function overwrites the contents of the "i" global variable, which is an unexpected side effect. Replacing :: Code :: for ( i = 0; i < a_all_cookies.length; i++ ):: Code :: for ( var i = 0; i < a_all_cookies.length; i++ )Back to top |
|||||
Calling this a bug is stretching it a bit, more of a wish list item, but I added an explicit var i = ''; declaration anyway since it is always good practice to declare and localize variables, though in this case there was no actual error in the script in terms of its own operation.
Back to top |
|||||
I guess it all depends whether or not you consider this function is meant to be used in larger programs. Call this function in a loop writen in the same style (with a global "i" as loop index) and you end up with a mess.
Back to top |
|||||
Pls, where is the original code that this Post fixes?
My first shot at cookies:
Pls, where is the original code that this Post fixes? Thanks...vmars316 Back to top |
|||||
click on the link in the first post.
Back to top |
|||||
All times are GMT - 8 Hours
|