iPhone Google Reader/Gmail/Facebook Cookie Fix

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: /var/mobile/Library/Cookies/Cookies.plist.

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!!

44 Comments

  1. Dude!!! found the link to here from your post on dermapthera.wordpress.com and I am seriously glad I did. I didnt realize how much i used the facebook app until I had to type my info in 40 times per session! I SSH’d into the phone and changed my permissions per your advice and it works perfect now! thanks!!!

  2. edit edit edit
    apparently I have no clue what i am talking about.. if you can delete the previous edit then please do so. But I want to give props to the forum that you posted this link on and it was definitely on macworld.. sorry for the edits and thanks again for the advice

  3. Hey thanks Travis. Yeah I cross-posted the fix on several forums. Note I’ve now worked out the *actual* problem (file ownership) which is a much nicer fix.

  4. edit edit edit
    apparently I have no clue what i am talking about.. if you can delete the previous edit then please do so. But I want to give props to the forum that you posted this link on and it was definitely on macworld.. sorry for the edits and thanks again for the advice

  5. Ben dude, it’s nice to see a *IHASIPHONE* post with actual, grunty nerd content.

    Good stuff *(now get back to the funk and post moar pics/stuff about the iPhone in your gloat thread)*

  6. Thanks so much – this was a massive problem driving me mad and you appear to have helped me solve it!!!

    Got to ask though -j how do you get that great Vodafone logo at the top? Mine is onOrange but I’d love to do the same!!!!

  7. Glad to help Phil.
    The vodafone logo came from the team at http://kiwi-ise.co.nz. I don’t think they have an Orange logo, but you could probably contact them to find out how they did it, so you can make your own.

  8. Glad to help Phil.
    The vodafone logo came from the team at http://kiwi-ise.co.nz. I don’t think they have an Orange logo, but you could probably contact them to find out how they did it, so you can make your own.

  9. Thanx heaps, this fix was an easy life saver

  10. This all seems great!
    One problem I don’t understand where to place that line of code?
    You said it’s in the iPhone file system, but how do I access and manually edit that and know where to place it, can someone please help me with that part?

    Cheers.

  11. Jason,

    You need to have a jailbroken iPhone. You also need to install the Term-vt100 package, which will give you a command line interface into the iPhone’s file system.

    Once you have that, open vt100, enter the password (usually ‘alpine’), then type in the commands.

  12. Jason,

    You need to have a jailbroken iPhone. You also need to install the Term-vt100 package, which will give you a command line interface into the iPhone’s file system.

    Once you have that, open vt100, enter the password (usually ‘alpine’), then type in the commands.

  13. any other way you can do that? terminal doesnt seem to work when i tried to login

  14. Sorry, if you’re running the 1.1.4 (or 1.1.3 I think) firmware, there’s also a “SUID Fix” installer package you need to install, otherwise the password won’t work. See here: http://osmethne.com/?q=node/9

  15. Dude…an iPhone? They’re not even 3G for goodness sakes!

  16. Stu, once you use one for a couple of days, it you’ll get over it :)

    Nah seriously, the GPRS speed is the *only* annoying thing about the iPhone. Everything else is as damn near perfect as I’ve ever had on a phone, and lordy knows I’ve had a few phones.

  17. Thanks for the solution,

    I just change the Cookies directory owner
    chown -R mobile /var/mobile/Library/Cookies

    That works for me,

    Anyone have the original permisions for
    /var/mobile/Library/Cookies/ and
    /var/mobile/Library/Cookies/Cookies.plist

  18. Thanks a million !

  19. Ok… this might sound like a really slow question as I have not seen anyone ask it, but for those who DONT KNOW….

    How do you “change ownership” and enter:

    chown -R mobile /var/mobile/

    I can access my iPhone via SSH and WinScp and reach root and stuff and change CHMOD

    But what is this change ownership and can U just PLEASE excuse me and help simplify that? Thanks.

  20. Mas, by typing that command (chown …) you are changing ownership of all files and directories inside /var/mobile.

    You don’t need to do anything else. No chmod or anything. Just type that chown command and it’s all fixed.

  21. thanks man. So great!!! =)

  22. Thanks a lot Ben,

    But WHERE do I type that exactly?

  23. Thanks a lot Ben,

    But WHERE do I type that exactly?

  24. Thanks a lot !!

  25. hey,
    first of all thank for the post.
    i ran into a problem and I wonder if you guys can help.
    I installed terminal and typed in the “chown” command in order to change ownership
    and got “changing ownership is not permitted” .
    can anyone try helping me please ?
    thanks

  26. hey,
    first of all thank for the post.
    i ran into a problem and I wonder if you guys can help.
    I installed terminal and typed in the “chown” command in order to change ownership
    and got “changing ownership is not permitted” .
    can anyone try helping me please ?
    thanks

  27. This worked for me also. Thanks for the tips!

  28. Thanks for the help. There are indeed many other help sites, but yours is the most readable and useful. Though, I did have trouble trying to do this right on the phone and ended up using ssh from my Mac and that worked great. I guess because when I was on the phone, root and alpine were not working but by logging in via ssh I could specify a user (root) and alpine worked fine. The ssh tip that helped me was at http://www.tuaw.com/2007/07/23/ssh-on-iphone/
    I had already installed afpd on the phone so had already dealt with that.

    Thanks again.

  29. Thanks for your investigative work, dude. Saved me doing it too – as they say – Google first, ask questions later. :) Legend.

  30. i have a lil probleme here each time i try to enter the fix i keep on getting “Operation Not permitted” am i doing something wrong here
    pls help
    thx

  31. Mourad Zaoui,
    I get the same thing when I try to do this fix. It hasn’t worked for me.

  32. Mourad Zaoui,
    I get the same thing when I try to do this fix. It hasn’t worked for me.

  33. SNIF SNIF

  34. Guess no ones around to help :(

  35. I’m not sure what the problem might be. Are you definitely logged in to SSH as root?

  36. logged in how do i do that …and iam not using shh iam using that term?inal thing

  37. Okay, so after some searching (and inability to install OpenSSH via Installer.app) I found Cydia (which is available via Installer). Install Cydia and you can then install OpenSSH. Once I did this I was able to login to root on term. To do this type “login” enter “root” press return, for password type “alpine” (passwords do not show up, even dots, in terminal but it does take the password). Press return. You should now see root# rather than mobile$ which indicates successful login as root. Once you have done this enter the string listed in the article and you will ownership will be corrected. Of interest, I did not get an echo of all the files modified, but it seems to have successfully corrected ownership. If you have changed your root password Cydia will apparently help you change it but I have no experience with this feature. Hope this helps!

  38. I found another solution that should be suitable to people not having jailbreaked iPhone, and therefore not able to ssh into it.

    The culprit file is corrrupted into your backup, so no matter how many time you restore your iphone, it will be restored as-is, and wrong.

    The solution is to delete it from your iphone backup before restoring :

    Open a terminal window, and type :

    grep ?Library/Cookies/Cookies.plist? ~/Library/Application\ Support/MobileSync/Backup/*/*

    If you have one backup, as most people do, you should have only one line as a result. delete this file from the mentioned directory, and restore again.

  39. Worked a treat – thanks!

  40. thanks dude…. it worked… u rock

  41. You are awesome!!!!!

  42. Worked for me!THANXX

  43. Thanks!! Worked using winscp and open ssh’d my phone

  44. My cookies file got horked after I upgraded to 2.2.1. I figured it was a permissions issue or something like that and sure enough… Besides chown’ing I also chgrp’d; the owner was set to root and the group was “507191” instead of mobile. Seems ok now.

Leave a Reply

Your email address will not be published.

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

© 2015 Ben.geek.nz

Theme by Anders NorenUp ↑