Win a copy of 97 Things Every Java Programmer Should Know this week in the Java in General 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
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
  • Piet Souris
  • 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.
The airline is called "Virgin"? Don't you want a plane to go all the way? This tiny ad will go all the way:
Devious Experiments for a Truly Passive Greenhouse!
    Bookmark Topic Watch Topic
  • New Topic