AshleyQuick Posted November 27, 2008 Share Posted November 27, 2008 I have a flash file with an animation that's on every page. It would be ideal if the initial animation doesn't keep playing as they browse the site. My thought is to create a second flash file without this animation to be displayed if their last page was the same domain. Can someone assist? Link to comment https://forums.phpfreaks.com/topic/134453-if-referring-page-was-same-domain-display-alternative-content/ Share on other sites More sharing options...
rhodesa Posted November 27, 2008 Share Posted November 27, 2008 Set a cookie when they come to the page. Then the flash file can read the cookie and see if it should play the animation. Or, with PHP, you can do a cookie or use session to see if they have been to a page already. Link to comment https://forums.phpfreaks.com/topic/134453-if-referring-page-was-same-domain-display-alternative-content/#findComment-700035 Share on other sites More sharing options...
AshleyQuick Posted November 27, 2008 Author Share Posted November 27, 2008 Can you assist? Perhaps with an example? I know very little php. Link to comment https://forums.phpfreaks.com/topic/134453-if-referring-page-was-same-domain-display-alternative-content/#findComment-700041 Share on other sites More sharing options...
rhodesa Posted November 27, 2008 Share Posted November 27, 2008 at the top of your pages, put this: <?php session_start(); $first = $_SESSION['first'] ? true : false; $_SESSION['first'] = true; ?> then, in the page, you can use the $first variable to see if it's the first time they have been to the page: <?php if($first){ ?> Put animated flash code here <?php } else { ?> Put non-animated flash code here <?php } ?> Link to comment https://forums.phpfreaks.com/topic/134453-if-referring-page-was-same-domain-display-alternative-content/#findComment-700048 Share on other sites More sharing options...
AshleyQuick Posted November 27, 2008 Author Share Posted November 27, 2008 Hmm, as I'm testing and going from page to page...it seems to work at times and other times it doesn't (the animated flash). Thoughts? Link to comment https://forums.phpfreaks.com/topic/134453-if-referring-page-was-same-domain-display-alternative-content/#findComment-700124 Share on other sites More sharing options...
rhodesa Posted November 27, 2008 Share Posted November 27, 2008 Can you elaborate more? The SESSION will last as long as the user's browser is open. Link to comment https://forums.phpfreaks.com/topic/134453-if-referring-page-was-same-domain-display-alternative-content/#findComment-700487 Share on other sites More sharing options...
AshleyQuick Posted November 27, 2008 Author Share Posted November 27, 2008 Here's what I'm using, based on my research. What do you think of this? The others didn't seem to work even after closing the browser, restarting, clearing the cache and authenticated sessions, etc. Top of pages: <?php $first = isset($_SESSION['first']); // Will be a boolean result $_SESSION['first'] = true; ?> placed in an include: <?php if($first){ ?> Animated content... <?php } else { ?> Non-Animated content... <?php } ?> Link to comment https://forums.phpfreaks.com/topic/134453-if-referring-page-was-same-domain-display-alternative-content/#findComment-700496 Share on other sites More sharing options...
rhodesa Posted November 27, 2008 Share Posted November 27, 2008 you are missing session_start() Link to comment https://forums.phpfreaks.com/topic/134453-if-referring-page-was-same-domain-display-alternative-content/#findComment-700538 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.