Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You probably want to start with the program so you can test it out, make sure it works correctly. Then afterwards, design the Authentication system or use someone else's.</p> <p>To implement the Authentication system, probably the best way is yes, a isRole() function that simply returns true or false whether the user is currently that role. It is simple, straight forward, and if you need multiple isRole() functions like isAdmin(), isMod(), isLogged(), etc, it is very easy to implement. </p> <p>Another solution would be to make a checkPermissions($permission), where the User has a set of IDs that represent permissions, and then that checks for the specific ID. There are many many ways to design an Authentication System.</p> <p><strong>Expanded</strong></p> <p>Let's say you have a list of IDs. (Add = 1, Edit = 2, Delete=3). You could store these variables in a string and save it somewhere. (The $_SESSION Varaible?) Later on, when you want to see a permission, you just grab the string, and explode it by a delimiter. Then simply check if the permission is in the resulting array. Example:</p> <pre><code>// User Permissions are in a string, delimited by '|' $string = "1|2"; $permissions = explode("|", $string); // This will return false; $check_permission = "3"; // This will return true; $check_permissions = "1"; if(in_array($check_permissions, $permissions)) { return true; } else { return false; } </code></pre> <hr> <p>For where to place the security, probably the best and most straight forward solution is to put it at the top of the script. </p> <pre><code> if(is_logged()){ echo "Logged In"; } else{ die("Denied"); } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload