Make page only accessible for certain users?

Hello everyone,

I am tying to make a page only accessible for certain users through a cookie.
I tried some script, but it doesn’t worked for me, because people could still see the scripts I am using on source code. I need to hide it completely and show the page only to people with the cookie.
So I need other alternative, maybe a auto-login through PHP before landing to my page?

Anyway, I’m open to ideas.

you could use .htaccess rules to allow only certain ips/locations…really depends how many users your allowing access to

I thought about .htaccess.

I am using funnels, so I can validate him to the page through a php that set a cookie.
Do you think I can adapt it to .htaccess? It would be good, because its faster.

It’s possible to allow the ips you set in htaccess. It would be even easier to just password the directory via plesk/cpanel if you’re using

IIt can’tr be done with JavaScript so why did you post the question in the JavaScript forum?

1 Like

Moved to Server Config.

lsw,

IMHO, you should be using PHP’s sessions (via cookies, normally) to control accesses to your webpages.

Personally, I’d never try to do this with server configuration (mod_rewrite) as that is not intended to be for security of individual web pages.

Staff, move to PHP?

Regards,

DK

I think unless @luckskywalker wants to use htpasswd - which IMHO would only be a realistic solution if there are a very limited number of users - a PHP SESSION approach would be better.

I must be missing something - doesn’t it make sense to move it to PHP then?

1 Like

Yeah PHP would be the best section.
Anyway do you think that would work?
A redirect page:

<?php
session_start();
$_SESSION['user'] = 'real_visitor';
?>

And then, in my index.php:

<?php 
session_start();
if($_SESSION['user'] != 'real_visitor'){
       header('Location: http://www.google.com.br/');
     exit;
} else {
     readfile("file.html");
}
?>

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.