06-12-2012, 12:33 PM #1Safari is using the usual cookie quota for all cookies
I am trying to store some user preferences for a website in a cookie. The amount of info I want to store exceeds what is allowed in one cookie (even after compression). So I split the info over two cookies.
IE, FF and Chrome are happy enough, but Safari appears to NOT be setting the second cookie when the size of the info exceeds the limit for one cookie.
Confused? So was I. I did tests. The info in the first cookie works fine. The second cookie contains about seven lines. I commented out various lines looking for rogue data. Eventually I found that with ANY two of the lines of the data 'live' (and the others commented out) the cookie would be set, but when I added any third line - the cookie would not set.
Has this happened to any one else?
I could reduce the amount of data stored, but that will require queries in a PHP forum!
06-12-2012, 12:47 PM #2
How much data are you storing? I only ask since cookies are really only meant to store limited amounts of data. Perhaps localStorage might be a better option.
Can you provide us with some relevant sample code and results?
06-12-2012, 01:20 PM #3
Thanks for your reply.
I don't how much exactly, but I know it was exceeding the limit because it wasn't working in IE and Google Chrome and FF so I split it up.
The data is,
shortname, shortname with spaces, long name, status, web link for 18 options. I have started splitting the data into two arrays (only name and status really need to be saved in a cookie) but as I hinted at in the question I am going to have to rewrite the PHP to link the two data sets.
The code is long and complex and I am not really expecting people to drag through it. I was hoping that someone had run into the same issue or new of a bug/syndrome that was causing the bother.
06-13-2012, 11:51 AM #4
I have found that:
- cookie 1 is 3442 bytes
- cookie 2 is 1744 bytes (this cookie doesn't read)
- the cookies were set at the same time
- another unrelated cookie - 10 bytes
- total: 5196 bytes
- Safari is not reading the second cookie correctly - it sets but doesn't read
- it doesn't matter which order or which code is used - the affect is the same.
06-13-2012, 11:59 AM #5
06-13-2012, 12:06 PM #6
Good test - the second cookie does now work in Safari
I think that it may be a timing error - the cookies are set too close together and one corrupts the other. If I inserted a command between the two cookie set commands that wasted some time it might help. OR if I moved some unrelated useful code between the two cookie sets.
06-13-2012, 12:18 PM #7
I put in a sleep command for 1 second - it made no difference.
Next I am going to disable the third cookie.
06-13-2012, 12:32 PM #8
I can't seem to remove the third cookie.
- I disable the code that creates.
- I remove it.
- it reappears
It contains the name of css file that controls the colour and is plain text.
06-13-2012, 12:49 PM #9
I have added dummy cookies:
- a duplicate of the working cookie (with different name) disables the previosly working cookie
- an additional dummy cookie containing one word leaves the situation as is.
06-14-2012, 05:29 AM #10
I have done the following:
- added the Windows version of Safari to my Windows 7 PC - it has the same issue as the Mac version.
- done more tests by removing lines of data - I have 18 lines of data - I have been remove lines from both cookies - it seems that I am 'allowed' 14 lines of data in both cookies - the split could be 12/2 or 11/3 or 7/7.
It would seem that I have found a 'read' quota limit for all cookies in Safari.
06-14-2012, 12:25 PM #11
I have sorted out the issue by reducing the size of the cookie. This was the right thing to do but leaves the safari issue somewhat unresolved. What I haven't is devise a test that proves that the is a size limit on all cookies in a safari session which just a little larger than the limit for one cookie.
Thanks for your help.
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
By dizzwold in forum OS X - Operating SystemReplies: 2Last Post: 11-05-2014, 12:58 PM
By sbatson in forum OS X - Apps and GamesReplies: 1Last Post: 06-13-2012, 05:52 AM
By malcolmi in forum OS X - Apps and GamesReplies: 0Last Post: 08-09-2011, 05:33 AM
By Zanthe in forum OS X - Apps and GamesReplies: 0Last Post: 06-13-2009, 10:40 AM
By calichris in forum OS X - Apps and GamesReplies: 5Last Post: 07-12-2008, 05:43 PM