
Originally Posted by
rdkd1970
This is my codes which work fine. Just need to know how to amend it to redirect them to payment.
I am not following you exactly, your request seems to be for a simple enough if/else
PHP Code:
<?php //Start session
session_start();
//Check whether the session variable SESS_MEMBER_ID is present or not
if( !isset($_SESSION['SESS_ID'])
|| (trim($_SESSION['SESS_ID']) == '')) {
header("location: access-denied.php");
exit();
}else{
header("location: payment-page.php");
exit();
}
?>
Is that what you mean? The question might then be how do you check the validity of the session?
That could be wrapped up in a function.
PHP Code:
function checkValidSession($session_id){
// do some kind of check and it is good
return true;
// otherwise
return false;
}
You may find checkValidSession() is a function you will use in other places too, you can put it into a file of its own and include it when you need it.
In that case the the check could become as simple as:
PHP Code:
// default action is to send away
$target_page = 'access-denied.php';
// overwrite the variable if the conditions are met
if( isset($_SESSION['SESS_ID'] && checkValidSession($_SESSION['SESS_ID') ){
$target_page = 'payment.php';
}
header('Location ' . $target_page);
exit;
Bookmarks