Protecting a cookie against user deletion

Posted on 2006-04-03
Last Modified: 2013-11-18
I want to store a cookie that the user will want to keep intact - it contains some preferences for site layout .

I know that Firefox has a plugin (called CookieCuller) which is presumably in js which alllows the user to protect cookies against accidental deletion.

Can someone give me some guidance as to how to do this?

Question by:Mutley2003
    LVL 35

    Expert Comment

    If you download the xsi file from here:

    To your hard disk, then you can open it with winzip (or similar), and look at the code inside cookieculler.jar (again open it with winzip)

    Basically, cookieculler just saves a list of "protected cookies" into its preferences, so that you cannot delete those cookies with "cookieculler"

    I assume that you can still delete cookies with the webdevelopers toolbar, etc?

    You can't just do this from javascript run on the webpage...


    Author Comment

    Thanks Tim

    There is a LOT  of code in that xsi file, and I don't pretend to understand it, but it is still just js, right?

    So, OK, CookieCuller only protects cookies from CookieCuller, but since js has no access to the filesystem how does it "save a list of protected cookies" ?  In a cookie?

    Or is it setting some special fields in those cookies (like ProtectedByCookieCuller=TRUE).. I guess that is a possibility, although surely screwing around with third party cookies is not safe.

    So, if we have a cookie containing a list of cookies, how do we know the browser will not delete that master cookie when it reaches its cookie limit? Or is my understanding of that flawed ?? I have this idea that browsers are free to kill cookies once the RFC prescribed limits are breached.


    LVL 35

    Accepted Solution

    No, it may be javascript code, but it is executed by the Firefox browser as if it is part of the browser..

    Basically Firefox allows plugins to be written in javascript

    And the firefox plugins can access preferences file for themselves by calling the Firefox API

    This can't be done from inside a webpage, as the javascript in a webpage will be running inside the security sandbox


    Author Comment

    ok, thanks Tim .. I understand now.

    I guess the only way I have of protecting the cookies is to write a small app (not js) that will allow the user to keep a copy of the cookie somewhere else in case it gets deleted, and then restore it. Or keep the preferences on the server

    thanks again
    LVL 35

    Expert Comment

    Good luck!  Sorry there wasn't an easier solution :-(

    And Thanks!


    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Join & Write a Comment

    Today I would like to talk about localizing (Internationalization) JavaScript applications. Introduction When creating an application that is going to be used by many people around the globe, it is important to remember that not everyone speak…
    Avoid defining the variables in the global scope; trying to define them in a local function scope. Because:   • Look-up is performed every time a variable is accessed.   • Variables are resolved backwards from most specific to least specific scope…
    The purpose of this video is to demonstrate how to set up the WordPress backend so that each page automatically generates a Mailchimp signup form in the sidebar. This will be demonstrated using a Windows 8 PC. Tools Used are Photoshop, Awesome…
    The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

    734 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    16 Experts available now in Live!

    Get 1:1 Help Now