# Sharedobjects... but how shared?

**URL:** <https://forum.kirupa.com/t/sharedobjects-but-how-shared/56541>\
**Category:** Uncategorized\
**Created:** [July 5, 2004, 5:21pm UTC](https://forum.kirupa.com/t/sharedobjects-but-how-shared/56541 "2004-07-05T17:21:51Z")\
**Posts on this page:** 5\
**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/56541/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 6, 2004, 10:40am UTC](https://forum.kirupa.com/t/sharedobjects-but-how-shared/56541/2 "2004-07-06T10:40:48Z")

</div>

Really no idea guys ?.. :\*(

Why can’t I get my sharedobject.data.firstname from that other swf ?

I can’t get it.

Look simple but really can’t get rid of that problem…

---

<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 6, 2004, 11:31am UTC](https://forum.kirupa.com/t/sharedobjects-but-how-shared/56541/3 "2004-07-06T11:31:17Z")

</div>

Well… me again :hugegrin:

In other terms, DOES ANYBODY MANAGE TO READ SHAREDOBJECTS THAT HAV BEEN CREATED IN A SWF, FROM WITHIN \*\*ANOTHER \*\*SWF (but placed beside the first one) ?

---

<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/56541/4 "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/56541/5 "2004-07-07T09:05:37Z")

</div>

Simple as that !

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