• View our reviews on Hot Scripts
  • JS Tutorial

Recent Comments

Powered by Disqus

Back to articles

Manage SharedObjects using Javascript

FCookie class can manage SharedObjects (aka Flash cookies) using swf file provided in package. It can set SharedObjects with different domain and namespace settings, retrieve saved values (preserving data types) and delete SharedObjects.

SharedObjects are similar to Cookies, only used by flash applications. They can not be deleted like regular cookies, only using special tools, and their values can be stored up to 100 Kb. They are crossbrowser (you can open manager_example.html in multiple browsers, set new values in one and refresh and check in others) and crossdomain (using "*" as domain setting and same namespace). More on SharedObjects.

Package contains fcookie.js and fcookie.packed.js (packed javascript), and 3 examples: simple_example.html(settting and retrieving value), datatype_example.html (to show datatype preservation) and manager_example.html (simple SharedObject manager created using this class).



Example codes

<script type="text/javascript" src="./fcookie.js" ></script>
<script type="text/javascript">
var fc = new fcookie({
    debug: true, 
    onload: function()

Examples in action

Example scripts provided with package in action:

Method list


Back to method list

Method namenew fcookie(config)
DescriptionCreates class instance with provided configuration
Input parameters

json config - json structure with configuration:

  • string path - path to swf file (default: './fcookie.swf')
  • string domain - which domains should be allowed to work with SharedObjects (default: '*' means any domain, just use same namespace)
  • bool debug - enable debug mode, fcookie.log() function recieves debug information from actionscript (default: false)
  • bool namespace - name of the SharedObject on users computer, use same value to access from other domains (default: 'fcookie')
  • function onload - callback function to notify when swf object is ready (default: empty function)

Check settings

Back to method list

Method namecheck;
DescriptionCheck user settings if it is possible to use SharedObjects

Set value

Back to method list

Method nameset(key, value);
DescriptionSave value to SharedObject by specifying key and value. Key will be used to retrieve value. It is possible to pass associative array as key parameter (without value), to save multiple object simoultaniously.
Input parameters

string or json key - key for the provided value or associative array with multiple key value pairs.

number, string, object, bool value - value for key if provided key is string. If key is associative array, then this value will not be used

Example inputfc.set("somekey", "somevalue"); or fc.set({"somekey1":"somevalue1", "somekey2":"somevalue2"})

Get value

Back to method list

Method nameget(key);
DescriptionReturns value from SharedObject by key, which was provided when saving value
Input parameters

string key - key of the value.

Example inputvar val = fc.get("somekey");

Get all values

Back to method list

Method nameget_all();
DescriptionReturns associative array with pairs (keys and values) of all saved SharedObjects

Delete value

Back to method list

Method namedel(key);
DescriptionDeletes SharedObject value with provided key
Input parameters

string key - key of the value.

Example inputfc.del("somekey");

Delete all values

Back to method list

Method namedel_all();
DescriptionDeletes all SharedObject values

Latest changes

None for now

Rate us

Like our script? Rate it at JavaScript > Hot Scripts

Try it out and Rate on


JS classes support forum or comments below

You may also be interested in:

Powered by

blog comments powered by Disqus