: How to show content for logged-in vs logged-out users? We have a set of pages with the following urls: www.mysite.com/info/page1.html www.mysite.com/info/page2.html www.mysite.com/info/page3.html Each
We have a set of pages with the following urls:
mysite.com/info/page1.html www.mysite.com/info/page2.html mysite.com/info/page3.html
Each has a structure as follows:
----------------------
| A |
|--------------------|
| | |
|B | C |
| | |
----------------------
| D |
|--------------------|
A: is the "header" area
B: is a list of menu items which show a bunch of menus, sub-menus and the
currently selected sub-menu
C: is the content, shown depending on what is selected on B
D: is a common footer to all
Our current solution is to manage everything not as html files, but as entries in a database table and to generate the html page depending on the url sought...
For example a mod_rewrite rule sends:
mysite/info/page1.html
to
showpages.php?url=page1
and that fetches the html for C from the DB table and shows the page properly.
I want to break away from this model because it is VERY slow on fetching large pages ("C").
My problems are two-fold:
The above pages need to be shown to a "logged-in" user, in which case the header ("A") is dynamically created.
With a view on maintainability, I DON'T want several copies of the same code (whether html or php to float around).
If I simply use pure html / js along with iframes I shouldnt have a problem displaying pages 1 to 4. However, I dont know how to manage the scenario when the user is logged in.
Can you provide more info to help us understanding the problem? Are you using a Content Management System?
no its a custom php website
Are you using frames?
actually we're not using iframes in our present setup, but am not averse to doing so if its makes sense in the ideal solution
How do you do the login now?
we have the login form on the "header section" (A) and when the user is logged in, it customizes the header.
Why is it that your current method is slower than other methods, if the content is the same?
Our current system picks up the content "C" from a table. Since the content is rather large, it slows the page load. I'm trying to move the html content from the db to an actual file on disk. If i just had to deal with logged-out / anonymous users, i would have used iframes to display (A), (B), (C) and (D). And with javascript, navigated to a different page and change contents of (C).
One more perteninet fact - I currently have a php script userheader.php which generates the html for both logged-in and logged-out users (ie "A").
More posts by @Rambettina238
1 Comments
Sorted by latest first Latest Oldest Best
I often use include()/require() for the various areas, so you could have...
include($_SERVER['DOCUMENT_ROOT']."/includes/header.php");
In "A" above. Then the logic to show/hide content based on permissions or a session variable (set after logging in) could show/hide various content.
Something like...
If(isset($_SESSION['logged_in'])){ ?>
<!-- html here to show when logged in --><?php
} ?>
<!-- html that's shown either way -->
Not sure if that covers what you're looking for. This way, you are checking a session vs. db hits or you hit the db once and set some local vars that filter down into the included files for evaluation.
Terms of Use Create Support ticket Your support tickets Stock Market News! © vmapp.org2024 All Rights reserved.