Tanner Ewing
Tanner Ewing

Reputation: 337

Get flash shared object from my domain

I am trying to clear flash cookies for a SWF that is hosted on my domain. Is it possible to get this flash cookie (sharedObject) so that it can be cleared? visiting this page shows my domain in the list of sites, but I want to be able to clear these from another SWF file which is drawn if the cookies are to be reset. Any help is appreciated!

Upvotes: 0

Views: 177

Answers (1)

Aaron Beall
Aaron Beall

Reputation: 52153

You can do this using SharedObject/clear() with some limitations:

  • The SWF that clears the shared objects must be on the same domain as the SWF(s) that created the shared objects.
  • The shared objects must be created with a path that both SWFs have access to. The easiest thing is to use "/" as the path so that all SWFs on the domain can access the shared object. The default path limits access to only the SWF that created the shared object.
  • You must know the exact names of all the shared objects. In other words you cannot query for all shared objects on a domain, you have to know the shared object names (and paths). (You can, of course, keep your own registry of shared objects in a single known shared object, though.)

For example:

domain.com/my/path/writer1.swf

var so:SharedObject = SharedObject.getLocal("savedData1", "/");
so.data.something = "Something";

domain.com/my/other/writer2.swf

var so:SharedObject = SharedObject.getLocal("savedData2", "/");
so.data.stuff = "Stuff";

domain.com/other/thing/writer3.swf

var so:SharedObject = SharedObject.getLocal("savedData3", "/");
so.data.thing = "Thing";

domain.com/eraser.swf

SharedObject.getLocal("savedData1", "/").clear();
SharedObject.getLocal("savedData2", "/").clear();
SharedObject.getLocal("savedData3", "/").clear();

or

var sharedObjectNames:Array = ["savedData1", "savedData2", "savedData3"];
for each(var sharedObjectName:String in sharedObjectNames){
    SharedObject.getLocal(sharedObjectName, "/").clear();
}

Note that when you use "/" as the path you must be careful not to have name collisions.

Upvotes: 2

Related Questions