Jump to content

How do I hide the contents of a page unless redirected?


jessnoonyes

Recommended Posts

I have a website where I sell one downloadable product.  Someone pays for it and then is redirected to the download page.  Problem is they could just bookmark the url and go back and download it again all they want.  Is there a way to prevent that from happening?  Somehow set it up so the page only displays if they've been redirected from PayPal perhaps? 

Link to comment
Share on other sites

I am such a novice when it comes to this.  I'm sorry!  Any help would really be appreciated.  So after a lot of looking around online I understand that a session can be started when a particular page is visited with the start session code, and that session info can be saved and passed along to subsequent pages and would eventually expire and die (right?).  Is this the code I use to start a session:

 

<?php

session_start(); //

?>

 

And then what do I put on the page I want protected to verify that the visitor didn't just type in the url but came from the start session page?

Link to comment
Share on other sites

<?php

session_start();

$_SESSION["redirected"] = true;

header("Location: x.php");

?>

 

<?php

session_start();

if(!$_SESSION["redirected"]) {
die("You are viewing this page incorrectly");
}

// Rest of page here

?>

Link to comment
Share on other sites

It didn't do anything  ??? I can still type in the url of the page and it opens up.  Wonder what I did wrong.  I put both those snippets of code above the html of the pages, and changed the x.php to the file.html page name I want protected.  Was that right?

Link to comment
Share on other sites

You need to make sure you are not doing this on the page you want protected:

 

<?php

session_start();

$_SESSION["redirected"] = true;

header("Location: x.php");

?>

 

If that code is on the page you want protected then it will always say that redirected = true.

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.