Page access restriction

They have: 3 posts

Joined: Mar 2006

I am a noob and need help with the following problem,

I am building a site on which 2 pages need to be restricted.
the first needs to be accessable only if redirected from payment centre this is in php.
the second is accessable after login as a redirect which is in html

I have no idea how to code this or where to place the code any advice would be great.

Thanks

Busy's picture

He has: 6,151 posts

Joined: May 2001

The payment center should offer redirect options shouldn't they?

you can set PHP up to use html extensions, so you can use (header: location.html) *before any screen output*

They have: 3 posts

Joined: Mar 2006

thanks for the advice. I got the payment redirect working.

but I still need help with members login access is there a code that will create a cookie that the restricted page will look for hence preventing access if not present and will redirect to the login page.

Busy's picture

He has: 6,151 posts

Joined: May 2001

To set a cookie:
setcookie("name","cookie-value",time()+(3600*24*365));

name= name of cookie
cookie-value = whatever you want it to equal (dont put passwords in there)

to set a session (which would become a cookie if cookies enabled)
session_name(SESSION_NAME);
$value = $_SESSION['IS_LOGGED'];

SESSION_NAME = name of session (same as it would be in cookie)
IS_LOGGED = can be anything
$value is the PHP variable that can be checked on pages you want to see if it's been set, like so:
if(!isset($_SESSION['IS_LOGGED']))
{
Header("Location: login.php");
exit;
}

Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.