TeddyKiller Posted April 2, 2010 Share Posted April 2, 2010 I have a page to display information to that user only. How do I protect it so that nobody else can access it? It's probably simple but I'm puzzled. Quote Link to comment https://forums.phpfreaks.com/topic/197409-how-can-i-protect-a-page-from-other-users/ Share on other sites More sharing options...
oni-kun Posted April 2, 2010 Share Posted April 2, 2010 I can safely assume the user has logged in. Simply place their user name within the current session (as people do for authenticated programs) and you can easily make this: //editdetails.php?id=24 An automated example if ($_SESSION['userid'] != $_GET['id']) { die('You\'re not authenticated to view this page!')); } //Authenticated content Of course that is a mockup example, and you should generate a solid system of how you handle the user's IDs appropriate for what you are doing, but authentication per user is as simple as that. Quote Link to comment https://forums.phpfreaks.com/topic/197409-how-can-i-protect-a-page-from-other-users/#findComment-1036194 Share on other sites More sharing options...
TeddyKiller Posted April 2, 2010 Author Share Posted April 2, 2010 Yeah. I was going to use a Hash for more security, I just thought.. it wouldn't work, yet it would, no it wouldn't. Though with some thinking, it would actually work. Thanks for putting my head straight! Quote Link to comment https://forums.phpfreaks.com/topic/197409-how-can-i-protect-a-page-from-other-users/#findComment-1036201 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.