{"id":15637577,"url":"https://github.com/nfriedly/javascript-flash-cookies","last_synced_at":"2025-10-16T09:32:28.211Z","repository":{"id":974611,"uuid":"772990","full_name":"nfriedly/Javascript-Flash-Cookies","owner":"nfriedly","description":"Cross-domain flash cookie library for javascript. ~ 4kb total when JS is minified and gzipped.","archived":false,"fork":false,"pushed_at":"2016-04-19T17:29:49.000Z","size":46010,"stargazers_count":106,"open_issues_count":4,"forks_count":29,"subscribers_count":16,"default_branch":"master","last_synced_at":"2025-03-04T22:48:14.679Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"http://nfriedly.com/techblog/2010/07/swf-for-javascript-cross-domain-flash-cookies/","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nfriedly.png","metadata":{"files":{"readme":"readme.md","changelog":"history.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2010-07-13T18:25:46.000Z","updated_at":"2024-09-19T16:12:22.000Z","dependencies_parsed_at":"2022-08-16T11:40:31.822Z","dependency_job_id":null,"html_url":"https://github.com/nfriedly/Javascript-Flash-Cookies","commit_stats":null,"previous_names":[],"tags_count":18,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nfriedly%2FJavascript-Flash-Cookies","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nfriedly%2FJavascript-Flash-Cookies/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nfriedly%2FJavascript-Flash-Cookies/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nfriedly%2FJavascript-Flash-Cookies/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nfriedly","download_url":"https://codeload.github.com/nfriedly/Javascript-Flash-Cookies/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245972665,"owners_count":20702721,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-03T11:12:11.183Z","updated_at":"2025-10-16T09:32:23.172Z","avatar_url":"https://github.com/nfriedly.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"SwfStore\n=======\n\nSwfStore is a JavaScript library for cross-domain flash cookies. It includes a .swf file that handles the\nstorage and a JavaScript interface for loading and communicating with the flash file.\n\nWorking example: https://nfriedly.github.io/Javascript-Flash-Cookies/ and http://nfriedly.com/stuff/swfstore-example/\n\n[![Bower package](http://badge.fury.io/bo/javascript-flash-cookies.svg)](http://bower.io/search/?q=flash%20cookies)\n[![Build Status](https://travis-ci.org/nfriedly/Javascript-Flash-Cookies.svg?branch=master)](https://travis-ci.org/nfriedly/Javascript-Flash-Cookies)\n\n---\n\nSecurity Warning\n----------------\n\nThe default storage.swf allows any website to read the data in your flash file. You should avoid storing private\ninformation in it. It would be wise to edit and recompile the flash file to limit itself to your domain and http/https settings. (See [src/Storage.as around line 93](https://github.com/nfriedly/Javascript-Flash-Cookies/blob/master/src/Storage.as#L93).)\nYou can do this yourself with Adobe Flash or the Apache Flex SDK (free) or I can do it for you for $5 - email me for details.\n\nAlso, versions older than 1.9.1 are vulnerable to a XSS attack and should not be used.\n\n\nCompatibility\n--------------\n\n[![Selenium Test Status (It also should work in older IE and Safari's, but the tests don't.)](https://saucelabs.com/browser-matrix/jsfc.svg)](https://saucelabs.com/u/jsfc)\n\nRequires Flash Player 9.0.31.0 or newer. Should be compatable with nearly all desktop browsers, assuming the user has Adobe Flash installed (or it's Google Chrome, which has flash player built in). Very few mobile browsers/devices support flash.\n\n\nInstallation\n-------------\n \nVia [Bower](http://bower.io/):\n\n    bower install --save flash-cookies\n    \nOr install via [npm](https://npmjs.com/) (for use with [browserify](https://www.npmjs.com/package/browserify):\n\n    npm install --save flash-cookies\n    \n\n\nUsage Notes\n-----------\n\nEnsure that the `storage.swf` file is available, Browserify won't make it public by default.\n\nCertain built-in keys such as `hasOwnProperty` cannot be overwritten in actionscript. A future version may detect this and throw an error.\n\nMost mobile devices will not work due to lack of flash support.\n\n\nBasic Usage\n-----------\n\n```javascript\n// this should run on DOMReady, or at least after the opening \u003cbody\u003e tag has been parsed.\nvar mySwfStore = new SwfStore({\n  namespace: \"my_cool_app\",\n  swf_url: \"//example.com/path/to/storage.swf\",\n  onready: function() {\n    mySwfStore.set('key', 'value');\n    console.log('key is now set to ' + mySwfStore.get('key'));\n  },\n  onerror: function(err) {\n    console.error(err.message);\n  }\n});\n```\n\nA more thorough example is also available at http://nfriedly.com/techblog/2010/07/swf-for-javascript-cross-domain-flash-cookies/\n\nConfiguration options\n---------------------\n\n* **`swf_url`**: URL to included `storage.swf` file. All sites/pages using SwfStore should have the exact same url here for cross-domain usage, and it should be a protocol-relative url (just // instead of http:// or https://) for cross-protocol usage.\n* **`namespace`**: Namespace used both internally for the JS object and for the LocalStorage Object (cookie). May contain forward slash (`/`) but all other special characters will be replaced with `_`\n* **`debug`**: Set to true to log debug information to the browser console (Automatically creates a logging `\u003cdiv\u003e` on the page if no console is available.)\n* **`timeout`**: Number of seconds to wait before concluding there was an error. Defaults to `10`.\n* **`onready`**: Callback function to fire once SwfStore is loaded and ready. No arguments.\n* **`onerror`**: Callback function to fire in the event of an error. Passes an `Error` object as the first argument.\n\nAPI\n---\n\nInstance methods:\n\n* **`get(key)`**: Returns the value for `key` as a String or `null` if the key is not set.\n* **`set(key, value)`**: Sets `key` to `value`.\n  * Note: setting a `key` to `null` or `undefined` is equivalent to `clear()`ing it.\n* **`clear(key)`**: Deletes the value for `key` if it exists.\n* **`getAll()`**: Returns a Object in the form of `{key: value}` with all data stored in the .swf.\n* **`clearAll()`**: Clears all data from the .swf.\n* **`ready`**: Boolean to indicate whether or not the .swf has loaded and is ready for access.\n  * Note: providing an `onready` callback to the config is recommended over checking the `.ready` property.\n\nTroubleshooting\n---------------\n * Be sure the urls to the .swf file and .js file are both correct.\n * If the .swf file is unable to communicate with the JavaScript, it will display log messages on the flash object. If debug is enabled, this should be visible on the page.\n * To hide the flash object and disable the log messages appending to the bottom of the page, set `debug: false` in the configuration options. (Log messages are added to a `\u003cdiv\u003e` if no browser `console` is available).\n * If the user does not have flash installed, the onerror function will be called after a (configurable) 10 second timeout. You may want to use a library such as [Flash Detect](http://www.featureblend.com/javascript-flash-detection-library.html) to check for this more quickly. Flash Player 9.0.31.0 or newer is required.\n * If you pass a non-string data as the key or value, things may break. Your best bet is to use strings and/or use JSON to encode objects as strings.\n * If you see the error `uncaught exception: Error in Actionscript. Use a try/catch block to find error., try using // in the .swf URL rather than https://. See https://github.com/nfriedly/Javascript-Flash-Cookies/issues/14 for more information.\n * Do not set display:none on the swf or any of its parent elements, this will cause the file to not render and the timeout will be fired. Disable debug and it will be rendered off screen.\n * The error this.swf.set is not a function has been known to occur when the FlashFirebug plugin is enabled in Firefox / Firebug.\n * This library is not sutable for storing large amounts of data because the .swf is normally rendered off screen and thus there is no way for the user to respond to Flash's prompt to increase the storage limit. \n\n\nFile Details\n------------\n\nstorage.swf is the compiled flash file ready to be embedded in your website. Note the security warning above.\n\nswfstore.min.js - a copy of swfstore.js, minified for your convenience. This and a copy of storage.swf should\nbe all you need to use this on a production website.\n\nswfstore.js handles the interaction between javascrpt and flash, it also handles embedding and some basic error\nchecking.\n\nStorage.as is where all the magic happens. It maps an External Interface to a Local Storage Object. I'm no expert when it comes to Flash / ActionScript, but it should be reasonably well documented and fairly safe.\n\nThe storage.fla is essentially just an empty shell file that points to Storage.as as it's main class.\n\nSee example/index.html for a working example that you can put on your site.\n\nCompiling\n---------\n\n### .js\nThis project uses [UglifyJS2](https://github.com/mishoo/UglifyJS2) via the [Grunt](http://gruntjs.com/) plugin. Setup:\n\n* Install [Node.js](http://nodejs.org/)\n* Install Grunt globally: `npm install -g grunt`\n* `cd` into the project directory and install the dependencies: `npm install`\n* Run `grunt uglify` to \"compile\" (minify) the JavaScript.\n\n### .swf\nThis .swf can be compiled using Adobe Flash (paid) or the Apache Flex SDK (free).\n\nWith Adobe Flash, open `src/storage.fla` and export it to `dist/storage.swf`\n\nGrunt is set up to use Apache Flex via the [grunt-swf](https://github.com/nfriedly/grunt-swf) plugin.\nThe plugin is installed via the standard `npm install` but the SDK must be installed separately.\n\nSee `flex-sdk/instructions.md` or https://github.com/nfriedly/grunt-swf#installing-the-apache-flex-sdk for more details on installing the Flex SDK.\n\nThen run `grunt swf` to compile the .swf.\n\nTip: `grunt build` will compile both the .js and the .swf.\n\n(Note: on Windows, Git Bash may give better results than the windows command prompt.)\n\nContributors\n------------\n* Nathan Friedly - http://nfriedly.com\n* Alexandre Mercier - https://twitter.com/alemercier\n* Andy Garbutt - https://twitter.com/techsplicer\n\n\nRelease process\n---------------\n* Update the the changelog in the readme\n* Compile anything that's changed (see the Compiling section above)\n* Commit everything\n* Run `npm version [major | minor | patch ]` with the appropriate flag (Ssee http://semver.org/ for details)\n* Push to Github - Travis CI will automatically run tests and publish when appropriate\n\n\nTo Do\n-----\n* Figure out how to run automated cross-domain \u0026 cross-protocol tests\n* update demo\n* Make automated tests less flakey\n* Look into http://karma-runner.github.io/ or http://theintern.io/ or similar to automate local testing.\n* Sourcemap\n\nChangelog\n---------\n\nSee [history.md](./history.md)\n\nMIT License\n-----------\n\nCopyright (c) 2010 by Nathan Friedly - http://nfriedly.com\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\nTHE SOFTWARE.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnfriedly%2Fjavascript-flash-cookies","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnfriedly%2Fjavascript-flash-cookies","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnfriedly%2Fjavascript-flash-cookies/lists"}