Question

My php question??

May 6, 2014 10:20PM PDT

How to secure php page from unauthorised access?

Discussion is locked

Follow
Reply to: My php question??
PLEASE NOTE: Do not post advertisements, offensive materials, profanity, or personal attacks. Please remember to be considerate of other members. If you are new to the CNET Forums, please read our CNET Forums FAQ. All submitted content is subject to our Terms of Use.
Reporting: My php question??
This post has been flagged and will be reviewed by our staff. Thank you for helping us maintain CNET's great community.
Sorry, there was a problem flagging this post. Please try again now or at a later time.
If you believe this post is offensive or violates the CNET Forums' Usage policies, you can report it below (this will not automatically remove the post). Once reported, our moderators will be notified and the post will be reviewed.
Comments
- Collapse -
Answer
My php question??
May 6, 2014 11:11PM PDT

Try this:

if(!isset($_SESSION['user_id']))
{
// The user id variable is not set. Therefore, the user is most likely a guest.
$_SESSION['user_id'] == 0;
}
if($_SESSION['user_id'] == 0)
{
// The user does not have a user id set. We assume, therefore, that they are a guest.
header("Location: login.php");
}

Also, in your login script, ensure that you are setting $_SESSION['user_id'] to anything other than 0.

- Collapse -
Answer
You could use Basic Auth to prompt for credentials
May 7, 2014 6:37AM PDT

CNET Forums

Forum Info