# Sharedobjects... but how shared?

**URL:** <https://forum.kirupa.com/t/sharedobjects-but-how-shared/115092>\
**Category:** Uncategorized\
**Created:** [July 5, 2004, 5:21pm UTC](https://forum.kirupa.com/t/sharedobjects-but-how-shared/115092 "2004-07-05T17:21:51Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jess](https://avatars.discourse-cdn.com/v4/letter/j/2bfe46/32.png) [@jess](https://forum.kirupa.com/u/jess)\
**Post date:** [July 5, 2004, 5:21pm UTC](https://forum.kirupa.com/t/sharedobjects-but-how-shared/115092/1 "2004-07-05T17:21:51Z")

</div>

🍺 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 🙂

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [July 7, 2004, 6:55am UTC](https://forum.kirupa.com/t/sharedobjects-but-how-shared/115092/2 "2004-07-07T06:55:23Z")

</div>

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:

```auto
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:

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

```

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [July 7, 2004, 9:05am UTC](https://forum.kirupa.com/t/sharedobjects-but-how-shared/115092/3 "2004-07-07T09:05:37Z")

</div>

Simple as that !

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