PHP-Login
PHP-Login copied to clipboard
Defining roles and the pages they get redirected to
I'm trying to set up a few different roles for users, various roles for standard users. When 1 type of new role logs in, I would like them to see a different page. There are pages, like page_2, page_3, etc... which is nice, but how do I attach roles to new pages so I can create page_6, page_7 and so on?
You’d want to use the $auth object that’s spawned in the pagehead file on page load and use the “hasRole” method. This returns true or false based on if the current user has the method that you pass it. From there you can redirect (or conditionally display content or whatever else you want) based on if it’s true or false.
Sent with GitHawk
Interesting. I'm trying that. In the mean time, when a user logs in, they click the login button, and get looped back to /login/index.php, but shouldn't it go to /index.php without the login? The user's session is valid and can navigate by the menu, it's just the login process. Where does that get set? I checked my DB and the base URL there is correct.
I've never had it loop back to the login page, and I'm unable to replicate the problem myself now. Could you list out the steps for me that you go through to cause that to happen?
I go to the login page, log in and it loops back to the login page. The URL doesn't change, but the top nav bar shows me logged in.
What webserver are you running? Also, what operating system/version?
All I can think off of the top of my head is some sort of configuration issue with your webserver or redirect rule messing things up. The PHP script is set to automatically redirect to the homepage if the login page is accessed while the user is already logged in.
It's a shared linux box. Kinda all I can dig up from the cpanel. Composer barely ran on my machine to set up the vendor file. I had to pull in the jquery and the bootstap css files manually. I
Also, thank you for your help here! It is truly appreciated!
Ah, I hate those shared servers, honestly. They always seem to cause all kinds of weird problems, and you have no control over the underlying system to solve them. Have you thought about using a cheap VPS provider instead like vultr or digitalocean? I'd highly recommend going for one of those over a shared hosting service.
No problem! Happy to help! Good luck to you :)
On Mon, Jun 18, 2018 at 1:51 PM, d_diddy [email protected] wrote:
Also, thank you for your help here! It is truly appreciated!
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/therecluse26/PHP-Login/issues/199#issuecomment-398139828, or mute the thread https://github.com/notifications/unsubscribe-auth/AH24AsrJobN7WdS7iFpcgeOOiEba1lvQks5t9-itgaJpZM4Uol3D .
HI,
I'm facing the same problem here, after login i'm still on the /login/index.php
istead of /index.php
.
Any idea?
Thanks
z