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 2 of 2
  1. #1
    TrainReq
    Guest

    need very simple code simplette

    so here is what i would like to accomplish.. basically and if/else function that uses cookies.. and here is how it works.


    So if the page with the sniplet is called upon one time, it will set a session cookie that will expire in 30 seconds named like visited=true , but it will expire in 30 seconds..

    but what i would like to acomplish with that is, if they do not have that session set, or if they visited after 30 seconds (after the session has expired), it will header locate to a page like nevervisited.php , but if they visit in the same 30 seconds (before the session expires), it will header locate to alreadyvisited.php

    so basically:

    if session cookie of visited is not set, or has expired, redirect to one page, but if it has been set and did not expire , redirect to another.

  • #2
    New Coder
    Join Date
    Nov 2007
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts
    to set the cookie for 30 seconds paste this:
    PHP Code:
    <?
    $value 
    "somevalue";
    setcookie('visited'$valuetime()+30);
    ?>
    on the page that checks if the cookie is there put this:
    PHP Code:
    <?
    if(isset($_COOKIE['visited']))
    {
        
    header'Location: http://www.yoursite.com/this_guy_deffinetally_is_in_session.php' ) ;
    }
    else
    {
    header'Location: http://www.yoursite.com/this_guy_needs_to_reactivate_his_session.php' ) ;
    }
    ?>


  •  

    Posting Permissions

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