Jump to content

How to redirect webpage to another webpage when refreshed or reloaded


samuel_lopez

Recommended Posts

Hi Barand, I want only to redirect to other page if I had refreshed the page.

 

for example,
user is currently at www.google.com,then when he refeshed/reloaded the page, he will be redirected to facebook.com.

 

 

In the example you provided, upon going to the page,it redirects to other page after accessing the first page.
Thank you
 

Link to comment
Share on other sites

You would need to set a session counter.The example assumes you dont want them back to the first page at all after refresh. (SESSION will still be set and keep redirecting)

<?php
   session_start();

   if( isset( $_SESSION['counter'] ) )
   {
    header('Location: http://www.example.com/');
   }
   else
   {
      $_SESSION['counter'] = 1;
   }
?>
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.