I’m trying for a long time now to build a cms handling users/roles/pages etc…
I thing I am on a very good stage and I have managed to finally do it but now I am on the stage to restrict page access/permissions based on users roles.
This brought me back a few steps back because I have to build in php all the needed SC I have already made.
Again, that’s fine but I am stuck on zero point because I can’t retrieve the user ID…
I have tried already:
security provider name “scname”.
<?php echo $_SESSION['scnameId'] ?>
Not working… Getting: Notice : Undefined variable: _SESSION in xxxxxxxxxxxx\index.php on line 49 Notice : Trying to access array offset on value of type null in xxxxxxxxxxx\index.php on line 49
I cannot figure what I am doing wrong…
Please, somebody have a suggestion?
When building a site with Wappler you can simply use the security provider enforcer which places the required code on your page to restrict access and not render the content to not authorized users.
Why are you using Wappler at all in case you want to hand code your site?
on your page.
Again, it would save you all of these issues if you use the components in Wappler and not hand-coding it. that’s the idea of using Wappler.
You solved the reason that my initial thread was about - session_start() was missing.
It didn’t work anyway because when I included session_start() I got a: Notice : Undefined index: scnameId
(Maybe because I used an example provider name in my thread “scname”, the actual name is “sc_name”. This underscore symbol maybe?)
Your insistence pointed me to the right direction, no hard coding…
And this direction came up from this post of yours: Wappler Documentation - Show or Hide Elements Conditionally
I will set a variable to “hide”. I will hide all of my content in the main div and set it as conditional region, its condition will be my variable == “show”.
Now, on my original SC I added a success event that a) set variable=“show” b) if SC gives permission a browser.goto (same page) but ticked internal otherwise browser.goto(login or index)
I hope I can make it happen (without hard-coding thanks to you).