When I use this script:
<?php
define("HTTP_AUTH_REALM", "Your authname here");
session_start();
if(!isset($_SESSION["uid"])) {
if(!isset($_COOKIE['login_attempts'])){
unset($_SERVER['PHP_AUTH_USER']);
setcookie('login_attempts', 1,time()+30);
}
if(!isset($_SERVER['PHP_AUTH_USER'])){
header("WWW-Authenticate: Basic realm=\"".HTTP_AUTH_REALM."\"");
header("HTTP/1.0 401 Unauthorized");
echo("This is for authorized users only.");
exit;
}
}
?>
I get a 500 server error.
PHP does not send correct the headers (maybe?)
Try it without the header informations.there is no error then.
I guess that is somthing with the php.ini.
Bellow is the session part of php.ini but i am not sure if this has anything to do with this.
Has anynone any ideas?
[Session]
session.save_handler = files
session.save_path = C:\ServerProgs\PHP\sessiondata
session.use_cookies = 1
session.name = PHPSESSID
session.auto_start = 0
session.cookie_lifetime = 0
session.cookie_path = /
session.cookie_domain =
session.serialize_handler = php
session.gc_probability = 50
session.gc_maxlifetime = 1440
session.referer_check =
session.entropy_length = 0
session.entropy_file =
;session.entropy_length = 16
;session.entropy_file = /dev/urandom
session.cache_limiter = nocache
session.cache_expire = 180
session.use_trans_sid = 0
url_rewriter.tags = "a=href,area=href,frame=src,input=src,form=fakeentry"
thanks very much