How to redirect a user to another page if the user already visit the same page link. (This is not a login page.)

383 views Asked by At

Please Help me ..!! How do I do this now ??

I want to make a redirect WebPage, where if a user comes the first time, then the user will see original page. But if the user visits or comes again in 1-2 days at the same page link then the page will automatically redirect to another page link.

(This is not a login page. It's just a simple PHP or HTML Web page.)

Please Help me, I want to do this.

1

There are 1 answers

1
Nijeesh Joshy On BEST ANSWER

you can do it either in php or in js

PHP

    $cookie_name = "redirect_cookie";
    $cookie_value = "true";
    if (!isset($_COOKIE[$cookie_name])){
      setcookie($cookie_name, $cookie_value, time() + (86400 * 30), "/"); // 86400 = 1 day
    } else {
         header("Location: <url>"); /* Redirect browser */
         exit();
    }

?>