Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 14 of 14
  1. #1
    New to the CF scene
    Join Date
    Jan 2012
    Posts
    8
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Skip Flash content with php session or cookies

    Hello!

    I hope that I will find answer and you could be very helpfyll. So the question is:
    I made flash based intro and placed it inside the index.php page, but I don`t want to play this flash content again and again for the person who are visiting my site second time. So I want to do some reforwarding to another page that holds all the content. But I don`t know how to do this. And which method could be better session or cookie.

    Can samone explain to me this.

    And thank you in advance!

  • #2
    Master Coder mlseim's Avatar
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,371
    Thanks
    8
    Thanked 1,075 Times in 1,066 Posts
    I would use a cookie.

    Post the PHP script you have for "index.php".

  • #3
    New to the CF scene
    Join Date
    Jan 2012
    Posts
    8
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Sorry, I don`t have any php code at all, but index page is simple plain code with flash embeding inside it.

  • #4
    Master Coder mlseim's Avatar
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,371
    Thanks
    8
    Thanked 1,075 Times in 1,066 Posts
    So your opening page is called "index.php" ... is that correct.

    What happens right now after the flash presentation is finished?
    Does it go to another page?
    And if so, what is the name of that other page (your main page)?

  • #5
    New to the CF scene
    Join Date
    Jan 2012
    Posts
    8
    Thanks
    1
    Thanked 0 Times in 0 Posts
    yes, I wrote Actionscript, that forwards the client to the main page when presentation is done. It`s another directory with index page in it.

    I know how to write Actionscript codes but do not know well php, probably i could do it in another way but my intropage in on directory web directory within index.php page, after intro is played, the script calls another direstory within main index page.

    index.php goes to /main/index.php

  • #6
    Senior Coder
    Join Date
    Jul 2011
    Posts
    1,226
    Thanks
    3
    Thanked 171 Times in 171 Posts
    Use a cookie .

    At the top of your index.php page (above any doctype or <html> tags - the VERY top of the document), you could put something like this:
    PHP Code:
    // Check for the cookie
    if(isset($_COOKIE['visited'])){ 
        
    // If it exists, set a boolean value
        
    $visited TRUE;
    else{
        
    // It doesn't exist - user has never been on this page before
        
    $visited FALSE;
        
    // Set the cookie with an expiry time 30 days from now
        
    setcookie('visited','true',time()+(60*60*24*30));

    Then, surround your flash content in an if condition like
    PHP Code:
    <?php
    if(!$visited){
    ?>
    <!-- FLASH CONTENT HERE -->
    <?php
    }
    ?>
    That should work
    Useful function to retrieve difference in times
    The best PHP resource
    A good PHP FAQ
    PLEASE remember to wrap your code in [PHP] tags.
    PHP Code:
    // Replace this
    if(isset($_POST['submitButton']))
    // With this
    if(!empty($_POST))
    // Then check for values/forms. Some IE versions don't send the submit button 
    Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live.

  • Users who have thanked BluePanther for this post:

    RaimoD (01-04-2012)

  • #7
    New to the CF scene
    Join Date
    Jan 2012
    Posts
    8
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Thank you, then I probably do on else statement all other main page coding? On this hand I dont need this another directory at all

  • #8
    Senior Coder
    Join Date
    Jul 2011
    Posts
    1,226
    Thanks
    3
    Thanked 171 Times in 171 Posts
    Quote Originally Posted by RaimoD View Post
    Thank you, then I probably do on else statement all other main page coding? On this hand I dont need this another directory at all
    You don't need an else for that if at all. It's just a check to display the flash content if $visited == false. If you wanted to stop the rest of the content being displayed at all, then you could add an else.

    To clarify: Adding an else isn't needed; it will stop first time viewers from being able to view anything other than the flash. However, if that is your required functionality, go right ahead
    Useful function to retrieve difference in times
    The best PHP resource
    A good PHP FAQ
    PLEASE remember to wrap your code in [PHP] tags.
    PHP Code:
    // Replace this
    if(isset($_POST['submitButton']))
    // With this
    if(!empty($_POST))
    // Then check for values/forms. Some IE versions don't send the submit button 
    Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live.

  • #9
    New to the CF scene
    Join Date
    Jan 2012
    Posts
    8
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Okey, but could you show me exapmle, if the statement visited is true, how can i redirect the client to another page?

  • #10
    Senior Coder
    Join Date
    Jul 2011
    Posts
    1,226
    Thanks
    3
    Thanked 171 Times in 171 Posts
    Now that I know the entirety of your problem, I would change my solution.
    PHP Code:
    if(isset($_COOKIE['visited'])){  
        
    // If it exists, redirect
        
    header("location: somewhere.php");
    else{ 
        
    // It doesn't exist - user has never been on this page before 
        // Set the cookie with an expiry time 30 days from now
        
    setcookie('visited','true',time()+(60*60*24*30));
        
    // Put entire page contents in here

    Useful function to retrieve difference in times
    The best PHP resource
    A good PHP FAQ
    PLEASE remember to wrap your code in [PHP] tags.
    PHP Code:
    // Replace this
    if(isset($_POST['submitButton']))
    // With this
    if(!empty($_POST))
    // Then check for values/forms. Some IE versions don't send the submit button 
    Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live.

  • Users who have thanked BluePanther for this post:

    tridentspk (01-17-2012)

  • #11
    New to the CF scene
    Join Date
    Jan 2012
    Posts
    8
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Thank you, you save may day!



    I should learn php as well.

  • #12
    New to the CF scene
    Join Date
    Jan 2012
    Posts
    8
    Thanks
    1
    Thanked 0 Times in 0 Posts
    And one more question
    // Put entire page contents in here

    so on this place I must start with all php and html elements as

    print <html><header> and so on...?

  • #13
    Senior Coder
    Join Date
    Jul 2011
    Posts
    1,226
    Thanks
    3
    Thanked 171 Times in 171 Posts
    Quote Originally Posted by RaimoD View Post
    And one more question
    // Put entire page contents in here

    so on this place I must start with all php and html elements as

    print <html><header> and so on...?
    Yeah, it should be
    PHP Code:
    if(isset($_COOKIE['visited'])){  
        
    // If it exists, redirect
        
    header("location: somewhere.php");
    else{ 
        
    // It doesn't exist - user has never been on this page before 
        // Set the cookie with an expiry time 30 days from now
        
    setcookie('visited','true',time()+(60*60*24*30));
        
    // Put entire page contents in here
        
    print '<html><head> etc. ';

    Or, if it's easier,
    PHP Code:
    if(isset($_COOKIE['visited'])){  
        // If it exists, redirect
        header("location: somewhere.php");
    else{ 
        // It doesn't exist - user has never been on this page before 
        // Set the cookie with an expiry time 30 days from now
        setcookie('visited','true',time()+(60*60*24*30));
        // Put entire page contents in here
        ?>
        <!-- Plain html in here. Additional PHP actions inside the html would be fine as well -->
        <?php
    }
    Useful function to retrieve difference in times
    The best PHP resource
    A good PHP FAQ
    PLEASE remember to wrap your code in [PHP] tags.
    PHP Code:
    // Replace this
    if(isset($_POST['submitButton']))
    // With this
    if(!empty($_POST))
    // Then check for values/forms. Some IE versions don't send the submit button 
    Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live.

  • #14
    New to the CF scene
    Join Date
    Jan 2012
    Posts
    8
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Thank you so much


  •  

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •