# \[FMX\] Javascript Cookie reading not working

**URL:** <https://forum.kirupa.com/t/fmx-javascript-cookie-reading-not-working/286020>\
**Category:** flash\
**Created:** [April 8, 2009, 9:08pm UTC](https://forum.kirupa.com/t/fmx-javascript-cookie-reading-not-working/286020 "2009-04-08T21:08:43Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![dinosf](https://avatars.discourse-cdn.com/v4/letter/d/ecccb3/32.png) [@dinosf](https://forum.kirupa.com/u/dinosf)\
**Post date:** [April 8, 2009, 9:08pm UTC](https://forum.kirupa.com/t/fmx-javascript-cookie-reading-not-working/286020/1 "2009-04-08T21:08:43Z")

</div>

Hey Guys - I’ve got a problem setting and getting a cookie value it doesn’t seem to be doing either one:

Any suggestions would be great

In Frame 1 I have this script

getURL (“javascript:getCookie(‘status’);”);  
status = status  
if (getBytesLoaded()==getBytesTotal()){  
gotoAndPlay(3);  
}

Frame 2 is

gotoAndPlay(1);

Frame 3 is

getURL(“javascript:set\_cookie( ‘status’, ‘visited’, 30 );”);  
if (status == “visited”) {  
gotoAndPlay(“Scene 5”, 1);  
}

For Reference Here is Javascript on the html page

\<script language=“JavaScript1.2” type=“text/JavaScript1.2”\>  
\<!–  
//  
function flashObj() {  
if(navigator.appName==“Netscape”) {  
return document.embeds[0]  
} else {  
return window[‘flash’]  
}  
}  
function set\_cookie ( cookie\_name, cookie\_value,  
lifespan\_in\_days, valid\_domain )  
{  
var domain\_string = valid\_domain ?  
("; domain=" + valid\_domain) : ‘’ ;  
document.cookie = cookie\_name +  
“=” + encodeURIComponent( cookie\_value ) +  
“; max-age=” + 60 \* 60 \*  
24 \* lifespan\_in\_days +  
“; path=/” + domain\_string ;  
}  
function get\_cookie ( cookie\_name )  
{  
var cookie\_string = document.cookie ;  
if (cookie\_string.length != 0) {  
var cookie\_value = cookie\_string.match (  
‘(^|;)[\s]_’ +  
cookie\_name +  
'=([^;]_)’ );  
return decodeURIComponent ( cookie\_value[2] ) ;  
}  
return ‘’ ;  
}  
//–\>  
\</script\>
