Jacques Posted August 18, 2015 Share Posted August 18, 2015 I have implemented "multiple types of administrators" as per Chapter 12 and have the following question. What does $SESSION['user_admin'] become in the header.html scrip to support the admin links in the dropdown menu? Any help will be much appreciated. Link to comment Share on other sites More sharing options...
Larry Posted August 20, 2015 Share Posted August 20, 2015 Sorry, I don't have the book in front of me. Can you expand upon how you implemented the multiple types of administrators? Link to comment Share on other sites More sharing options...
Jacques Posted August 20, 2015 Author Share Posted August 20, 2015 // Validate the password: if (password_verify($p, $row['pass'])) { // Correct. // Create a new session ID to be safe: if ($row['type'] === 'user_id') { session_regenerate_id(true); $_SESSION['user_type'] = $row['type']; } // Store the data in a session: $_SESSION['user_id'] = $row['id']; $_SESSION['username'] = $row['username']; // Validate the password: if (password_verify($p, $row['pass'])) { // Correct. // If the user is an administrator, create a new session ID to be safe: if ($row['type'] === 'admin') { session_regenerate_id(true); $_SESSION['user_admin'] = true; } // Store the data in a session: $_SESSION['user_id'] = $row['id']; $_SESSION['username'] = $row['username']; Hi Larry, Thank you for your response. The first block of code is the original from the login.inc.php script, and the second block after multiple types of administrators have been added. In the "users" table the "type" column has been changed to SMALLINT and a table "user_types" with columns "id" and "type" and values (1, 'member'), (50, 'author'), (100, 'editor'), (150, 'admin') created. I hope it helps. Link to comment Share on other sites More sharing options...
Larry Posted September 3, 2015 Share Posted September 3, 2015 Sorry for the delayed reply! It's not clear what links you want to create, but I'd be inclined to store the user type in a session and then rewrite the toggle in the header file to change what links are shown based upon the actual user type. (This depends, again, on what you actually want to do for the different user types.) Link to comment Share on other sites More sharing options...
Recommended Posts