468,103 Members | 1,222 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,103 developers. It's quick & easy.

why won't this code work?

I got this snippet online and for the life of me I can't seem to make it
write the cookie....
The Flash has the labels mentioned in the code and I used the name=movie and
the swconnect=true as mentioned in the comments.
The movie is fine.....the code is just not writing the cookie at all...
Could someone take a look and see if you can figure out why it won't work?

Thanks,

FayeC

Code as follows:
<script language="javascript">
////////////////////////////////////////////////////////////////////////////
/////
// makeCookie is called when the page loads and only sets the cookie
// if the user does not have one.
// we can communicate with the swf by naming it in the <object> and <embed>
tags
// in the <object> tag you will see id=movie and
// in the <embed> tag i put name=movie swLiveConnect=True
// a list of javascript methods for flash are available at
www.macromedia.com/support/flash
// and type javascript methods into the search box
////////////////////////////////////////////////////////////////////////////
/////
function makeCookie(){
var movie = window.document.movie;
movie.StopPlay();
// only makes the cookie if don't have one
if(document.cookie == "") {
// play the intro
movie.Play();
// the cookie expires on this date
var date = new Date();
date.setDate(date.getDate() + 30);
// make the cookie date readable by the browser
var da_date = date.toGMTString();
var da_cookie = "visited:True" + ";expires=" + da_date;
document.cookie = da_cookie;
//uncomment the alert below to see the cookies value
//alert(da_cookie)
}

else
// if they have the cookie - fire the readIt function
readIt()
}
////////////////////////////////////////////////////////////////////////////
/////
function readIt(){
var movie = window.document.movie;
// this tells the .swf which frame to go to
// it could send any number of commands to the .swf
// send the movie to frame 3
movie.TGotoLabel("/", "no_sound");
}
////////////////////////////////////////////////////////////////////////////
/////
</script>
Jul 23 '05 #1
1 1403
In article <b6********************@news20.bellglobal.com>,
"FayeC" <fa**********@sympatico.ca> wrote:
The Flash has the labels mentioned in the code and I used the name=movie and
the swconnect=true as mentioned in the comments.
I am not familiar with flash.
The movie is fine.....the code is just not writing the cookie at all...
Could someone take a look and see if you can figure out why it won't work?

// only makes the cookie if don't have one
if(document.cookie == "") {


The variable document.cookie contains all cookies created for this
path/domain. Some other program running out of the same directory may
have created a cookie that you are not aware of.

do an alert to see what is in the cookie:

alert(document.cookie);
I suggest you use an existing set of cookie routines. see this post for
some:

http://groups.google.com/groups?hl=e...b75ff.04071407
20.7fe9333b%40posting.google.com&rnum=6

Re: Javascript cookies?

Here are some more lines from the post:

Here are my suggestions.

1) Always set the expiration time. IE works better.

2) You may have disabled cookies. In IE, I had to go to the site then
check whether or not cookies were enabled.

3) Maybe your cookie rountines could use improvements.

Robert
Jul 23 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

16 posts views Thread by Kerry Neilson | last post: by
1 post views Thread by Jim | last post: by
5 posts views Thread by John Warner | last post: by
7 posts views Thread by simon | last post: by
11 posts views Thread by John Ortt | last post: by
7 posts views Thread by Eran.Yasso | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.