The first thing I'd like to ask is that you be gentle with me, I haven't written any PHP in a long time.
With that out of the way, here's my problem; I need to password protect some pages on a website I'm administering. It's a Drupal 8 site but none of the available modules work for me, unfortunately, so I thought I'd just a little PHP script because what I need is fairly simple.
Here's the logic of what I want;
- If the url = mysite.com/members/ (or if there's anything after that slash)
- Check if session is set
- If yes - allow access
- If no - send to login page
- If password correct - set session and allow access
It's simple because of the way the website works (I didn't set this up). There's one password and everyone who needs to know it, knows it, and if they enter it, they should get access to the whole members section.
So, this is my current script (brace yourself, it's ugly);
I've also been trying to dump out the session data but even that doesn't work. Probably because this script is just all wrong.