Samuel Martin

Greenhorn
+ Follow
since Feb 12, 2020
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Samuel Martin

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.
1 week ago
PHP