View Full Version : need very simple code simplette

11-28-2007, 03:40 AM
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.

11-28-2007, 04:53 AM
to set the cookie for 30 seconds paste this:

$value = "somevalue";
setcookie('visited', $value, time()+30);

on the page that checks if the cookie is there put this:

header( 'Location: http://www.yoursite.com/this_guy_deffinetally_is_in_session.php' ) ;
header( 'Location: http://www.yoursite.com/this_guy_needs_to_reactivate_his_session.php' ) ;