Create admin panel with session

hello
i want create admin panel with session.
do must session_id save to database?

No you don’t need to save a session to the database!

So with session, what to Do?
How to manage access levels?

Depending on the server side scripting you use, you create/set a session upon a certain event (can be submission of a form). In PHP


<?php session_start(); ?>

I think that the primary concern for the OP is how to actually create an admin panel.

Tricky, that one.

I don’t think that there is much in the way of useful tutorials, but it should be possible to gather together enough info on how to from here:
http://www.phpfreaks.com/forums/php-coding-help/how-to-make-an-admin-panel/

Mmm :scratch: You’re probably right. That is indeed not just 1, 2, 3 explained, since here we talk about a combination of sessions and stored database content

Thanks
I could make my admin panel with session.
Manager for the scheme what should I do? (access level for management)
member admin with limitation. (user admin restriction)

Like said before. You should read into PHP sessions. This is not just a mather of giving you some code and it’s working. Try to understand sessions first!

Here’s a quick way to control access.


<?php
$permissions = array(
  'post.create' => 1,
  'post.read'   => 2,
  'post.update' => 4,
  'post.delete' => 8
);

$roles = array(
  'visitor'       => $permissions['post.read'],
  'member'        => $permissions['post.create'] | $permissions['post.read'],
  'editor'        => $permissions['post.create'] | $permissions['post.read'] | $permissions['post.update'],
  'administrator' => $permissions['post.create'] | $permissions['post.read'] | $permissions['post.update'] | $permissions['post.delete']
);

function user_can_access(array $user, $permission){
  return $user['role'] & $permission;
}


Visitor


$user = array(
  'name'  => 'Anthony Sterling',
  'role'  => $roles['visitor']
);

foreach($permissions as $name => $permission){
  printf(
    "%s %s access %s\
",
    $user['name'],
    user_can_access($user, $permission) ? 'can' : 'cannot',
    $name
  );
}

/*
  Anthony Sterling cannot access post.create
  Anthony Sterling can access post.read
  Anthony Sterling cannot access post.update
  Anthony Sterling cannot access post.delete
*/

Member


$user = array(
  'name'  => 'Anthony Sterling',
  'role'  => $roles['member']
);

foreach($permissions as $name => $permission){
  printf(
    "%s %s access %s\
",
    $user['name'],
    user_can_access($user, $permission) ? 'can' : 'cannot',
    $name
  );
}

/*
  Anthony Sterling can access post.create
  Anthony Sterling can access post.read
  Anthony Sterling cannot access post.update
  Anthony Sterling cannot access post.delete
*/

Editor


$user = array(
  'name'  => 'Anthony Sterling',
  'role'  => $roles['editor']
);

foreach($permissions as $name => $permission){
  printf(
    "%s %s access %s\
",
    $user['name'],
    user_can_access($user, $permission) ? 'can' : 'cannot',
    $name
  );
}

/*
  Anthony Sterling can access post.create
  Anthony Sterling can access post.read
  Anthony Sterling can access post.update
  Anthony Sterling cannot access post.delete
*/

Administrator


$user = array(
  'name'  => 'Anthony Sterling',
  'role'  => $roles['administrator']
);

foreach($permissions as $name => $permission){
  printf(
    "%s %s access %s\
",
    $user['name'],
    user_can_access($user, $permission) ? 'can' : 'cannot',
    $name
  );
}

/*
  Anthony Sterling can access post.create
  Anthony Sterling can access post.read
  Anthony Sterling can access post.update
  Anthony Sterling can access post.delete
*/

Adapted from this user comment over at the manual page for [URL=“http://www.php.net/manual/en/language.operators.bitwise.php”]Bitwise Operators.

thanks
Please explain?
What should I do with these codes?
Where the database used?
Where session used?

The code I posted only shows you how to manage permissions.

As pmw57 states, I’m afraid your going to have to look elsewhere if you need every element of an admin panel.

Do you have a list of the features you need yet?

yes,
i want create an admin panel that have a general manager and several subsidiary manager for special page.this subsidiary manager create by general manager.
example:
pmw57 is general manager
AnthonySterling is subsidiary manager for section contact us.
binboy is subsidiary manager for section support.
and …
How do I start?
(please guide me)
summary:created to manage access levels. ok?

you don’t need to save a session to the database!