naveen
naveen

Reputation:

Flash+PHP+cookie

I want an animation play only once in the browser. If any user seen the movie and if goes to any other page or refresh(F5) and then come back on the animation page then animation should not play from start. I want to play it from another frame.

I think it can be done by set cookie or somthing using javascript or php.

Please anybody help me. Thanks in advance. I will appreciate ,if some code help please

Upvotes: 0

Views: 1593

Answers (4)

skateboard
skateboard

Reputation: 31

Don't forget to set the string $domain to '/' or maybe they don't work on all subdirectories. Regards.

Upvotes: 0

meouw
meouw

Reputation: 42140

You could do something like this

<?php
session_start();

$animation_start = isset( $_SESSION['seen_animation'] ) ? 'animation_start=middle' : 'animation_start=start';
$_SESSION['seen_animation'] = true;
?>

<!-- simplified flash embed -->
<object width="550" height="400">
    <param name="movie" value="myflash.swf" />
    <param name="FlashVars" value="<?php echo $animation_start ?>" />
    <embed src="myflash.swf" width="550" height="400" FlashVars = "<?php echo $animation_start ?>"></embed>
</object>

You will have a global variable in your swf called 'animation_start' which will contain 'start' or 'middle' to let you know where to play your movie from

Upvotes: 1

&#211;lafur Waage
&#211;lafur Waage

Reputation: 70001

You can set a session

session_start();

And then set a session variable after the flash data

$_SESSION["noflash"] = true;

And do a check above the flash

if(isset($_SESSION["noflash"]) && $_SESSION["noflash"] == true)
{
    // set the correct flashvars
}

That way the session data is set after the flash is initialized, and the session data is still on when the user comes to the site again.

Upvotes: 1

Jan Hančič
Jan Hančič

Reputation: 53931

With PHP you can set a cookie with the SetCookie function. In JavaScript you set it like this.

Upvotes: 0

Related Questions