This week's book giveaways are in the Jython/Python and Object-Oriented programming forums.
We're giving away four copies each of Machine Learning for Business: Using Amazon SageMaker and Jupyter and Object Design Style Guide and have the authors on-line!
See this thread and this one for details.
Win a copy of Machine Learning for Business: Using Amazon SageMaker and JupyterE this week in the Jython/Python forum
or Object Design Style Guide in the Object-Oriented programming forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Bear Bibeault
  • Paul Clapham
  • Jeanne Boyarsky
  • Knute Snortum
  • Liutauras Vilda
  • Tim Cooke
  • Junilu Lacar
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
  • Joe Ess
  • salvin francis
  • fred rosenberger

Simple PHP auth system

Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 = (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.
Yes, of course, and I accept that blame. In fact, i covet that blame. As does this tiny ad:
Sauce Labs - World's Largest Continuous Testing Cloud for Websites and Mobile Apps
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!