Macworld Forums: Bugs & Fixes: Solving Safari cookie problems - Macworld Forums

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Bugs & Fixes: Solving Safari cookie problems

#1 User is offline   Macworld Icon

  • Story Poster
  • Icon
  • Group: MW Bot
  • Posts: 12,886
  • Joined: 30-November 07

Posted 16 October 2009 - 04:40 AM

Post your comments for Bugs & Fixes: Solving Safari cookie problems here
0

#2 User is offline   TeaEarleGreyHot Icon

  • Member
  • PipPip
  • Group: Members
  • Posts: 349
  • Joined: 29-September 05

Posted 16 October 2009 - 06:04 AM

"This did permanently fix the problem at last—but at the cost of losing several MB of perfectly fine cookies."

I fail to understand the author's attachment to cookies. I view them as nothing more than a convenience to the website designers and the advertisers who wish to track usage. They don't provide any benefit to me, and I routinely purge all cookies. Several times a day, sometimes after specific website visits. The Reset Safari function is good for this. I only wish there was a more convenient way to purge flash cookies--which I view as an insidious form of spyware.
0

#3 User is offline   stephen520 Icon

  • Member
  • PipPip
  • Group: Members
  • Posts: 30
  • Joined: 01-June 09

Posted 16 October 2009 - 06:48 AM

I've thought cookies were creepy since I first learned about them umpteen years ago. I routinely turned on and off my "accept cookies" option, and deleted cookies I didn't want. (Some cookies are helpful--e.g., from my bank website--which keeps me from having to identify my computer each time I log in.)

Then I discovered SafariCookies. I can set "favorite" domains, and delete all non-favorites with a single click. SC also optionally removes Flash cookies and Google analytics cookies when quitting Safari. (Works in Leopard and Snow Leopard; versions available for pre-Leopard operating systems.)

http://sweetpproduct.../safaricookies/
0

#4 User is offline   TeaEarleGreyHot Icon

  • Member
  • PipPip
  • Group: Members
  • Posts: 349
  • Joined: 29-September 05

Posted 16 October 2009 - 08:23 AM

What APPLE really needs to do is implement a few new tabs in OS X's "Security" control panel (System Preferences). They need a tab for "Viruses" a tab for "Cookies", and a tab for "Caches". The "viruses" tab would utilize an Apple-coded virus checker/remover utility. The "cookies" tab would have a utility to clear *all* cookies from a list of user-selectable browsers (for custom-clearing of cookies, leave it up to the user and browser), AND a utility to clear all flash cookies, and any other type of cookie that might arise. The "caches" tab would clear not only all browser caches, but also system-event logfiles, installer logfiles, and other logfiles which can grow interminably.
0

#5 User is offline   n4hhe Icon

  • Member
  • PipPip
  • Group: Members
  • Posts: 143
  • Joined: 13-June 05

Posted 16 October 2009 - 10:39 AM

"I did this while Safari was running (which I am aware is not recommended). It had absolutely no effect. Indeed, if I returned to view the list of cookies in Safari’s Preferences, it remained unchanged. All the pre-existing cookies were still listed. I figured Safari must be accessing the removed file. So I deleted it. But the cookies list in Safari did not change!"

Time for a fundamental Unix lesson here: Deleting ("unlinking" in Unix terminology) a file only removes its entry from the directory so that no one else can find it to open. The file ("inode" in Unix terminology) is not released until closed by the last application that has it open.

A common Unix-y thing to do is create a temporary scratch file and immediately unlink(2) delete it. This way on exit or application crash one doesn't have to remember to clean up. The OS will do it for you. But meanwhile the temporary file is still perfectly usable until close(2).

Notice how a Mac will not complain about deleting a file that an application has open the way Windows will complain. Then again its impossible to tell from most applications if it has a file open or whether its a document cached in memory. Whether "Save" re-opens the file then closes or writes to an already opened file.
0

#6 User is offline   mschmitt Icon

  • Newbie
  • Pip
  • Group: Members
  • Posts: 7
  • Joined: 26-June 07

Posted 16 October 2009 - 12:21 PM

"with Safari running, trash the 4KB file and drag the the larger 2.3MB file to the Cookies folder. Within a second, the 2.3MB file drops to 4KB in size, as its data are replaced with those from the deleted file!"

It sounds like to improve performance, Safari isn't reading the cookie file every time a cookie is requested. Instead it must read the entire cookie file into memory at the beginning of the session. To ensure the cookies are saved in the event of a crash, it probably periodically writes the memory copy back to disk.
0

#7 User is offline   Cog3125 Icon

  • Member
  • PipPip
  • Group: Members
  • Posts: 52
  • Joined: 07-November 08

Posted 16 October 2009 - 02:19 PM

I would have been surprised that your cookies kept being overwritten with the in-memory versions (although as mschmitt observes, it's most likely for performance reasons) right up until the point where you said the phrase"Cookies.plist"

Any plist file is merely an XML file consisting of a dictionary of name value pairs, most typically used for storing persistent settings for an application but now that you mention it, is an ideal format for storing web browser cookies as well. I know, even from being a very casual Cocoa hobbyist, that a plist can be read or saved by the NSDictionary class, which is a common enough Cocoa utility class.

So it follows from the behavior described in the article that Safari must instantiate a new NSDictionary object to hold cookies and initialize it with the contents of the cookies.plist file from the current user's Library. Then, as mschmitt already observed above, Safari would (naturally enough) periodically save the cookies back to file (probably each time a browser cookie changes value). Hence, when you deleted the file, it achieved nothing because the next time a cookie changed, the file you tried to create got overwritten.

The surprising part is the fact that you had used Safari itself to delete the cookie and didn't get a fix. That suggests that the in-memory cookie is not flushed (for some reason) when you delete the cookie in Safari and soon overwrites the files with the faulty cookie again.

The only explanation I can think of for behavior like this is if the preferences panel, rather than accessing the main in-memory dictionary of cookies instead loads its own temporary copy, let's you do your thing to it, then saves it again. If this is the case, the main browser would need to receive a notification of this event in order to know to reload its own cookies from file. If it doesn't (and it looks like it's not in this case), then the original in-memory version you didn't want is still lurking about waiting to clobber your freshly fixed file next time Safari feels its time to save cookies.

It definitely sounds like a minimal little bug in the way cookies work. Thanks for sharing the workaround you discovered!
0

#8 Guest_MarkElliot_*

  • Group: Guests

Posted 16 October 2009 - 09:20 PM

I have simply emptied the cookies plist file while Safari was not running and then locked it using Finder. Now, when I accumulate cookies they are in effect temporary, and the file is dumped on quit.
I too don't understand the attachment to cookies. I'm horrified at the thought of MBs of this tracking tool!
0

#9 User is offline   elroth Icon

  • Member
  • PipPip
  • Group: Members
  • Posts: 82
  • Joined: 17-January 06

Posted 17 October 2009 - 05:23 PM

View PostMarkElliot, on 16 October 2009 - 09:20 PM, said:

I have simply emptied the cookies plist file while Safari was not running and then locked it using Finder. Now, when I accumulate cookies they are in effect temporary, and the file is dumped on quit.
I too don't understand the attachment to cookies. I'm horrified at the thought of MBs of this tracking tool!


I like your solution - I keep cookies off, and erased, and only turn them on when needed. Your way solves the cookie problem with iTunes 9 - iTunes 9 won't let you buy anything from the iTunes Store if you have Safari cookies disabled (and don't have an old apple cookie residing there).The funny thing is, even if Safari is closed, as long as cookies are enabled it will allow iTunes to set cookies there. I don't know why Apple requires this in iTunes 9, and I don't like it.

TeaEarlGrey: As far as Flash cookies, there's a way to set preferences in Flash to not allow cookies. You do it through a website, where you can set the security preferences for your Flash plugin.

http://www.adobe.com...layer/security/
0

#10 User is offline   soupnh Icon

  • Newbie
  • Pip
  • Group: Members
  • Posts: 3
  • Joined: 06-January 04

Posted 19 October 2009 - 04:04 AM

What about cookies from other sites that keep appearing even when I have the security set to accept cookies only from sites I visit or not at all?

I've deleted the cookies.plist and can't find any others.
0

#11 User is offline   springkeeper Icon

  • Newbie
  • Pip
  • Group: Members
  • Posts: 1
  • Joined: 20-October 09

Posted 20 October 2009 - 04:51 AM

This doesn't happen only with the apple.com site. I've had problems for a while with nytimes.com. I thought it was their site's problem with cookies. Thank you for the solution!
0

#12 User is offline   Peter Icon

  • Newbie
  • Pip
  • Group: Members
  • Posts: 1
  • Joined: 20-October 09

Posted 20 October 2009 - 07:17 AM

View PostTeaEarleGreyHot, on 16 October 2009 - 06:04 AM, said:

"This did permanently fix the problem at last—but at the cost of losing several MB of perfectly fine cookies."

I fail to understand the author's attachment to cookies. I view them as nothing more than a convenience to the website designers and the advertisers who wish to track usage. They don't provide any benefit to me, and I routinely purge all cookies. Several times a day, sometimes after specific website visits. The Reset Safari function is good for this. I only wish there was a more convenient way to purge flash cookies--which I view as an insidious form of spyware.


There's a very easy way to get rid of flash cookies - Flush.app - check it out on http://machacks.tv
0

#13 User is offline   MrMarkie Icon

  • Newbie
  • Pip
  • Group: Members
  • Posts: 1
  • Joined: 06-November 09

Posted 06 November 2009 - 10:16 PM

The one problem I've discovered is that Safari consistently writes an error to the console log when the cookies file is locked:

2009-11-06 22:11:09.963 Safari[21257] Could not open cookie file "/Users/User/Library/Cookies/Cookies.plist" for reading.
2009-11-06 22:11:23.575 Safari[21257] Could not open cookie file "/Users/User/Library/Cookies/Cookies.plist" for reading.
2009-11-06 22:11:56.427 Safari[21257] Could not open cookie file "/Users/User/Library/Cookies/Cookies.plist" for reading.
etc.

I've tried making it read-only but I don't think that this has solved the issue. In addition, I notice that (unexpectedly) another app accesses the Safari cookie file:

2009-11-06 21:48:34.595 GimmeSomeTune[221] Could not open cookie file "/Users/user/Library/Cookies/Cookies.plist" for reading.
2009-11-06 21:59:38.419 GimmeSomeTune[221] Could not open cookie file "/Users/user/Library/Cookies/Cookies.plist" for reading.

I'm not sure what to make of it, but if suggestions abound, drop a few right here. This Safari cookie issue, already well-documented, is a real frustration and will drive me to Firefox eventually.
0

#14 User is offline   michaelegret Icon

  • Newbie
  • Pip
  • Group: Members
  • Posts: 1
  • Joined: 07-November 09

Posted 07 November 2009 - 10:00 PM

Sorry, I've never used the Macworld Community before and don't yet know how to enter a new topic so I entered this where I saw the line about Safari problems. I'm posting this for a friend in China who is apparently not the only one experiencing this problem. They are asking for any ideas on what to do about it.

"Hey Net Surfers,
For over a year now, EVERY time I log onto the internet
and click on "Safari," which is default set to Google, ALWAYS
the first thing that comes up in the box is the link below,
61.166.151.90/welcome etc. So I close the window, click
Safari again, and Google comes up.
I checked and there is no way to open the 'welcome site,'
nor track it down. So I looked on Chinese language google,
and there are dozens of blog complaints about this from
Chinese browsers, such as the one below, and no one has
any idea what it is.
Any of your cyberheads got any ideas on this?

Recently found that the use of surf the Internet, whenever the first double-click surf browser, the Internet, originally set the home page not open, but shifted to the http://61.166.151.90...come/index.html web page, the second set to open its own home page, I do not know why, reinstall systems can not be solved.

Please expert research to help resolve."
0

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

3 User(s) are reading this topic
0 members, 3 guests, 0 anonymous users