This post was going to be all about how I finally caved and bought an iPhone, but instead it is a treatise on open systems, and an explanation about how to fix an annoying bug with Safari on the iPhone.
I’ve had an iPhone for about 3 days, and am loving it. However, it had an extremely irritating bug whereby cookies wouldn’t seem to ‘stick’ in Safari. Symptoms:
- I’d log into GMail, and my login details wouldn’t carry over to Google Reader
- After logging into Google Reader, I’d be prompted again to login after about a minute of browsing stories
- Same with Facebook. Sometimes login wouldn’t work, sometimes I’d be re-prompted for my login
I presumed this was an issues with a jailbroken phone, but then I saw others with the same issue. After hunting around in the iPhone filesystem for a bit, I found the location of the Cookies file:
Looking inside that cookies file (cat it or something), I saw no sign of Facebook or Google accounts. On a whim, I checked the permissions, and they were very restrictive, so I did the old “open to all” chmod:
chmod 777 /var/mobile/Library/Cookies/
chmod 666 /var/mobile/Library/Cookies/Cookies.plist
(If you want to know all about chmod and what I’m doing with those commands, here is an explanation).
On further investigation, I’ve worked out that the ownership of the Cookies folder and file are wrong. On some phones, they seem to be owned by ‘root’, and need to be owned by ‘mobile’. Here’s the code to fix the ownership of the files:
chown -R mobile /var/mobile/
Et voila! It worked! After logging in to Facebook, I went back and looked at the Cookies.plist file, and there, plain as day, was a big fat Facebook cookie. GMail and Reader share an authentication cookie, and I’ve not been prompted for another login. At least one other reader over on the Apple forums confirms the fix works.
Ideally of course, I should find out the identity that Safari is running under, and provide access to that one identity, but for a quick and dirty fix, chmod 777 is fine. After all, your Cookies file is not particularly exciting if someone does manage to pwn your iPhone. Done! Chown mobile is a much tidier fix than chmod 777
Now here’s the deal kids: some people with pristine, locked iPhones are having this issue. They are completely outta luck and will have to live with this issue until Apple issue a fix. Those of us with ‘open’ hardware on the other hand (thanks to the help of myriad hackers), can diagnose, locate, and resolve our own issues. Just like the Maker’s Bill of Rights says.
Now do you understand why locked-down hardware and systems are bad? Did I just break the DMCA by fixing my iPhone?
Update: Madness. I had searched for ages to find a solution to my problem, but now that I’ve solved it, a Google search for the solution turns up tons of hits. Damn Google!!