These days I encountered a situation that I cannot set and get a cookie's value properly.
I used Fiddler tool to check about the cookie value and discover that there are two cookies with same name. I didn't realize what's the problem initially and tried to set it expire. But it still doesn't work.
Finally, after searching in Google, I realize that multiple cookies can have same name but in different path. What I need to do is to set the path when setting the cookie's value. For example,
document.cookie = "login=" + loginName + ";path=/";
If you don't set the path, you may have two cookies, one in your root directory and one in your sub-directory.
This is also a reminder for me not to have this mistake again.
Wednesday, March 11, 2009
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment