Well, I have stumbled across something very interesting today. I have been working with browser based cookies to keep track of a user's activities and found the need to delete them upon logout. After much headache, it was brought to my attention on another blog (http://blogs.bytecode.com.au/glen/2006/03/31/1143750630535.html) that it is not sufficient to just set the max age of a cookie to 0. The reason being that your "delete cookie" routine has to be aware of the correct domain/path settings on that cookie. If you call your creation routine to recreate the cookie (with a known path/domain) and then set the max age to 0 on that cookie object before setting the cookie on the response, you can be sure that the cookie will truly be immediately removed.
Monday, December 10, 2007
Xmas Cookies!
The problem with this solution for me was that our creation routine returns not the cookie, but a boolean value as to wether the cookie was created or not. Rather than rewriting this logic, I thought of of another solution that may work for you. If possible, however ugly, you can always overwrite the existing cookie with some useless value, such as a spaces, and use that as a control in addition with checking to see if the cookie exists.
Another does of sugar came with the news that I am now engaged! I asked my girlfriend, Caroline, to marry me this past Saturday and she said yes. We are both very excited and I thought I would share!
Posted by S.G. at 9:19 AM
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment