24, July 2008

showing data based on acces level - webmaster forum

 
Webdigity webmaster forums
This forum shares its ad revenue with its members!
[ Home | Help | Search | Forum's Shop | Archive | Login | Register | Webmaster Directory ]
Webdigity Webmaster Forums  >  Web Development  >  PhP  >  PHP classes @finalwebsites.com  >  3rd party modifications (Moderator: Olaf)
Topic: showing data based on acces level
« previous next »
Pages: [1] Print

Author Topic: showing data based on acces level  (Read 442 times)
Cyberpunk Wannabe
*
Gender: Male
Posts: 43
280 credits
Members referred : 0


Lolo means Grandpa in the Philippines!


« on: Feb 07, 2007, 03:40:49 AM »

if one want a simpler check just using session ?

using the $_SESSION['logged_in'] variable and just checking it ?

session_start();
if (!$_SESSION['logged_in'])
{
header ("Location: login.php");
}

Hi nitrixud,

We have a working educational site, but you might not want to do this if you are a site dealing in money!

We successfully added a...
$_SESSION['access_level']
with just a couple mods.

You can see the these at:
http://www.webdigity.com/index.php/topic,5503.0.Adding+%24_SESSION%5B%27access_level%27%5D+to+the+class.html Visit through proxy

We use this to show different educational levels (menus and pages) based on the access_level in the database.

We use:

Quote
 
   if ($_SESSION['access_level'] > 0) {
      echo 'logged in stuff' :
   } else {
      echo 'not logged in stuff' :
   }
 

To test if a person is logged in...

Because our site builds, meaning each access_level may view its educational level and any level beneath it we can use a simple test too, like these...

Quote
   
   if ($_SESSION['access_level'] > 1) {
      echo 'Stuff for levels above 1' ;
   }

   if ($_SESSION['access_level'] > 2) {
      echo 'Stuff for levels above 2' ;
   }
   

And we put our admin page in a "hidden" location...

Quote
   
   if ($_SESSION['access_level'] == 255) {
      echo 'Stuff for Admin_level' ;
   }
   

This works well but I would not use it for anything dealing with money or national security!  Smiley

Likewise, if you modify the class, you do it at your own risk.  We have asked Olaf to add this, and his answer seemed to be in agreement, but until he does, you will have to modify your class with each new release.  That is what we do!

For us, this is a great little mod.  Quick and easy to do.

PS: This little mod also adds the ability to declare additional
$_SESSION['anything_you_want'] VARS without having to worry about tearing them down at logout.  For example, add them to an extension class!

PPS: If all you want is to test if a person is logged in or not, you could try this code... we use it to display a login box as well as the appropriate links for:


Quote

           Register Here
           Forgot Password
           Change Profile
           Logout
 

Quote
   
   if (isset($_SESSION['user'])) {
      echo 'logged in stuff' :
   } else {
      echo 'not logged in stuff' :
   }
   
« Last Edit: Feb 07, 2007, 03:46:30 AM by Lan »
Trackback URI for this entry : http://www.webdigity.com/trackback.php?topic=5994
Bookmark this thread : Digg Del.icio.us Dzone more....

Topic sponsors:
Get a permanent link here for $1.99!


Pages: [1] Print 
Webdigity Webmaster Forums  >  Web Development  >  PhP  >  PHP classes @finalwebsites.com  >  3rd party modifications (Moderator: Olaf)
Topic: showing data based on acces level
« previous next »
Jump to:
User Area
Welcome, Guest. Please login or register.
Did you miss your activation email?
Jul 24, 2008, 11:49:27 PM





Login with username, password and session length

Donate to our community, and get a permanent link back to your site!

Donate to our community, and get a permanent link back to your site!


Forum Statistics
Total Posts: 35.717
Total Topics: 7.379
Total Members: 3.711
Tutorials : 56
Resources : 143
Designs : 220
Latest Member: Asimina

30 Guests, 5 Users online :

11 users online today:



Readers

Web Design Gallery · Whois Lookup · Pagerank · Tag Browsing · Lo-fi version · Syndication · Webmaster forum history · Advertise
Developed by HumanWorks © 2005 - 2008 Webdigity webmaster community · sublime directory
Webdigity Webmaster Forums | Powered by SMF 1.0.12. © 2001-2005, Lewis Media. All Rights Reserved.