This topic is locked
[SOLVED]

 Custom Files - Php - Security

3/21/2013 4:47:30 PM
PHPRunner General questions
N
netmedia59 author

Hello,
Is there a way to add some security to a simple php custom file

For example, I want the user to be allowed to open a custom file only if he is logged

So, if I use an email and a password for security in my project, if the user is not logged, he can't open the php custom file !

Thanks
Olivier

Lille (FRANCE)

T
Tempus_Erus 3/21/2013



Hello,
Is there a way to add some security to a simple php custom file

For example, I want the user to be allowed to open a custom file only if he is logged

So, if I use an email and a password for security in my project, if the user is not logged, he can't open the php custom file !

Thanks
Olivier

Lille (FRANCE)


Hi,
Try something like:
include("include/dbcommon.php");

if(!@$_SESSION["UserID"]){

header("Location: login.php");

return;}
if(!@$_SESSION["UserID"])

{

$_SESSION["MyURL"]=$_SERVER["SCRIPT_NAME"]."?".$_SERVER["QUERY_STRING"];

header("Location: login.php?message=expired");

return;

}

N
netmedia59 author 3/22/2013

Thank you very much Tempus_Erus !

It works as expected !
Olivier