vendredi 20 octobre 2017

Best way to make $_SESSION permissions?

I have been working in a project using only PHP, HTML, CSS and a little bit of JS, without any framework, but now I'm getting in some trouble because of $_SESSION, my login SYSTEM relies on a primary ID, that I get from SQL, so the problem is that basically everything on my page is inside an IF, for example:

if ($_SESSION['ID'] == "999"){
    //Shows admin page content
}else{
    // shows user content
}

And inside of the ADMIN if there is another one when I select the user I want to modify, that I get from one $_POST from an html select, its something like that:

$_SESSION ['edit'] = $_POST['ID'];
if(is_null($_SESSION ['edit'])){
     //shows the html select menu
}else{
    //navigate through the selected user, that i can edit, delete files etc.
 }

So the problem is that $_SESSION seems very buggy on my project, for example when I delete something and refresh the page, the $_SESSION ['edit'] continues with the same value but it takes me to the select menu. I can't see any solution for that, so is there any way to do that better?




Aucun commentaire:

Enregistrer un commentaire