Imagine a script executed in a dispatch-method like manner (so calls to example.com/ example.com/stuff, and example.com/stuff/cool/12 all go to the same script). It stores the value (12 in the last example) in a session for later use. Printing out that value on the page, doing weird things with it, etc. all work. You always get 12. Even printing out the value from the session as the last thing in the script then exiting, you still get 12. Load up another page, you get 0.
Is that even possible?
It turns out what was happening was my script was displaying information in a template, that was including another resource (say <img src=”image.png” />). The browser was obligingly requesting example.com/stuff/cool/image.png, which was re-executing the script, casting image.png over to an integer, resulting in a 0.
The fundamental stumbling block in my diagnosis of the issue was that I saw my browser making two requests, the first when I was being presented with a 12, the second when I was shown a 0. In fact my browser was making three requests, the first directly at my request for the page (setting the value), the second by my implied request to retrieve a referenced image (resetting the value), the third for the page showing zero.
Things that helped me debug the issue: IRC, (Daniel Banck in #zftalk), and Christine
Things I should have used, Firebug or Dragonfly to watch the requests go by.
Something I would love to have: An application that watched a file on disk, reporting all versions of the file over time. tail -f wont work as the file is a single line long, the line is changed but no new lines are added. I’m aware of similar tools for windows, none for mac/linux.