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.
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).
Contents
Download
Example codes
<html> <head> </head> <body> <script type="text/javascript" src="./fcookie.js" ></script> <script type="text/javascript"> var fc = new fcookie({ debug: true, onload: function() { fc.set("key","value"); alert(fc.get("key")); } }); </script> </body> </html>
Examples in action
Method list
Constructor
| Method name | new fcookie(config) |
| Description | Creates class instance with provided configuration |
| Input parameters | json config - json structure with configuration:
|
Check settings
| Method name | check; |
| Description | Check user settings if it is possible to use SharedObjects |
Set value
| Method name | set(key, value); |
| Description | Save 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 input | fc.set("somekey", "somevalue"); or fc.set({"somekey1":"somevalue1", "somekey2":"somevalue2"}) |
Get value
| Method name | get(key); |
| Description | Returns value from SharedObject by key, which was provided when saving value |
| Input parameters | string key - key of the value. |
| Example input | var val = fc.get("somekey"); |
Get all values
| Method name | get_all(); |
| Description | Returns associative array with pairs (keys and values) of all saved SharedObjects |
Delete value
| Method name | del(key); |
| Description | Deletes SharedObject value with provided key |
| Input parameters | string key - key of the value. |
| Example input | fc.del("somekey"); |
Delete all values
| Method name | del_all(); |
| Description | Deletes all SharedObject values |
Latest changes
None for now
Rate us
Try it out and Rate on JSclasses.org
Support
JS classes support forum or comments below
You may also be interested in:
Powered by BlogAlike.com










