Security isseu

T

T. Wintershoven

Hello all,

My website is built in HTML and PHP.
On it, there is a menu wich visitors can use to go to the pages.
Some pages are secured by PHP code to make sure that only people who are
logged in can access them.
But.....
If a visitor types the address (URL) to a certain secured page directly in
the addressbar of the browser, he/she can still access this page despite
he/she is not logged in at all.

Question:
Is there a way to avoid this problem and give a visitor, who accesses a page
without using the menu, a kind of warning and redirect to the homepage.

Thanks in advance.

Regards,

Tino Wintershoven
 
B

Beauregard T. Shagnasty

T. Wintershoven said:
Hello all,

My website is built in HTML and PHP. On it, there is a menu wich
visitors can use to go to the pages. Some pages are secured by PHP
code to make sure that only people who are logged in can access them.
But..... If a visitor types the address (URL) to a certain secured
page directly in the addressbar of the browser, he/she can still
access this page despite he/she is not logged in at all.

Question:
Is there a way to avoid this problem and give a visitor, who accesses a page
without using the menu, a kind of warning and redirect to the homepage.

Yes, you have to use a global or session variable at the start of each
of the pages. If it is false, redirect to the main page. Set it to true
on the login page.

$lauthorized = $_SESSION['gblauthorized'];
if ($lauthorized <> true ) {
header("Location: index.php");
exit;
}

You could also use "Y" or other key letter or phrase instead of true.
 
U

UKuser

Hello all,

My website is built in HTML and PHP.
On it, there is a menu wich visitors can use to go to the pages.
Some pages are secured by PHP code to make sure that only people who are
logged in can access them.
But.....
If a visitor types the address (URL) to a certain secured page directly in
the addressbar of the browser, he/she can still access this page despite
he/she is not logged in at all.

Question:
Is there a way to avoid this problem and give a visitor, who accesses a page
without using the menu, a kind of warning and redirect to the homepage.

Thanks in advance.

Regards,

Tino Wintershoven

Hi Tino,

I put a code in the top of each page to check for the presence of a
cookie I create when they login.

If its not there I redirect them to the login page or give them an
error.

Hope that helps

A
 
U

UKuser

Hi Tino,

I put a code in the top of each page to check for the presence of a
cookie I create when they login.

If its not there I redirect them to the login page or give them an
error.

Hope that helps

A

Be aware as well - sessions are fine if you're on a dedicated server
but on a shared server - sessions can be accessed by other scripts on
the same server unless the tmp folder is protected.
 
B

Beauregard T. Shagnasty

UKuser said:
Be aware as well - sessions are fine if you're on a dedicated server
but on a shared server - sessions can be accessed by other scripts on
the same server unless the tmp folder is protected.

I've never had a problem on a shared server.
 
J

Jonathan N. Little

Be aware as well - sessions are fine if you're on a dedicated server
but on a shared server - sessions can be accessed by other scripts on
the same server unless the tmp folder is protected.

If concerned your can set the session folder to another...

session_save_path($_SERVER['DOCUMENT_ROOT'] ."/mytemp");

Just have to make sure the permissions on the folder are set...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,431
Messages
2,571,678
Members
48,796
Latest member
Greg L.

Latest Threads

Top