Sharedobjects... but how shared?

:beer: Salut salut !

I create and populate a sharedobject in A.swf, like this :

var myCookie = SharedObject.getLocal(“user_profile”);
if (myCookie.data.firstname == undefined) {
myCookie.data.firstname = “cowboy”;
myCookie.flush();
}
else {
myCookie.data.firstname = “cowgirl”;
myCookie.flush();
}

I want to retrieve this stored data, in B.swf, which is located beside A.swf, like this :

**var myCookie = SharedObject.getLocal(“user_profile”);
myTextfield.text = myCookie.data.firstname;
**

The problem is that I always get “undefined” in place of “cowboy” or “cowgirl”.

:ogre:

What I’m doing wrong ?

thxx a lot :slight_smile:

In order to share the SharedObject between different swf movies, you need to set the path in your getLocal statement after the name of the SharedObject. In this case, just set the path to the current folder:

A.swf:

var myCookie = SharedObject.getLocal("user_profile","/");
if (myCookie.data.firstname == undefined) {
myCookie.data.firstname = "cowboy";
myCookie.flush();
}
else {
myCookie.data.firstname = "cowgirl";
myCookie.flush();
}

B.swf:

var myCookie = SharedObject.getLocal("user_profile","/");
myTextfield.text = myCookie.data.firstname;

Simple as that !

it works now, thxx for your answer **Jerryscript **:thumb: