Safari SecurityError: Dom Exception 18 thrown by localStorage or cookies are blocked

Please note an unhandled SecurityError (DOM Exception 18): The operation is insecure is thrown when calling window.localStorage from Safari on iOS 7.1.2 with blocked cookies (Settings > Safari > Block Cookies > Always).

It is caused by disabling cookies also disables localStorage. With other two choices of block cookies setting (“From third parties and advertisers” and “Never”) everything works fine.

It means no cookie and no localStorage and only solution is putting all in a try-catch block and have a silent failure.

Resource:

Leave a Reply

Your email address will not be published. Required fields are marked *

CAPTCHA