Re: restrict access to multiple pages
| From: | Justin French | Date: | Tue, 09 Dec 2003 03:16:50 +0000 |
| Subject: | Re: restrict access to multiple pages | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-172216@lists.php.net to get a copy of this message | ||
On Tuesday, December 9, 2003, at 12:08 PM, Chris W. Parker wrote:
Hey y'all. Ok so I am working on the admin sectin of the e-commerce app I'm writing and I'm hoping there's a better way to do what I am currently doing. In an effort to prevent circumvention of the login page I've placed a check at the beginning of each page that basically does the following: <?php if(loggedin()) { // entire page of code goes here } else { // redirect back to login page } ?>That's essentially what I do too... except I've got all this stored in a restricted.inc file which I just include() where needed. I think you can minimise your code though, by checking (in my case) for an invalid uid or a uid without admin clearance (redirect and exit), otherwise just show the page: --- <?php if(!$_SESSION['uid'] || !$_SESSION['admin']) { header("Location: login.php"); exit; } ?> the rest of your page here --- Cheers, Justin