Jump to content

access a secure page by changing the url


Mr P!nk

Recommended Posts

how can i stop people getting into a secure logged in page by just typing

www.somesite.co.uk/admin/index.php.

 

theres a login set up, but i can bypass it by just entering the url location, this is a major security issue that i need to solve relatively quickly before i publish the pages.

 

what i need/want is if someone isn't logged in it just goes to a page saying "you must be logged in to access this page" then prompts them to login.php.

 

 

thanks

 

 

Link to comment
Share on other sites

Yes, you will need to register a session after the user logs in

 

This is a function that checks if a user is authed

function is_authed_user()
{
     // Check if the encrypted username is the same
     // as the unencrypted one, if it is, it hasn't been changed
     if (isset($_SESSION['username']))
     {
          return true;
     }
     else
     {
          return false;
     }
}

 

On the page where you want to secure use something like this

<?php

    if (!is_authed_user()) 
    {
print ('You need to login to view this page, <a href="/login">click here</a> to login.');
include('login.php');
    }
    else
    {
            print('You ARE allowed to view this page
    }
?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.